{"id":21387474,"url":"https://github.com/nju33/context-modal","last_synced_at":"2025-03-16T12:29:00.601Z","repository":{"id":57206507,"uuid":"86207834","full_name":"nju33/context-modal","owner":"nju33","description":"Display related elements with axis of trigger element","archived":false,"fork":false,"pushed_at":"2017-03-26T14:05:54.000Z","size":1221,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-22T12:13:16.335Z","etag":null,"topics":["context","dropdown","library","menu","modal","pure-javascript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/context-modal","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nju33.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-26T04:39:39.000Z","updated_at":"2017-03-26T04:54:59.000Z","dependencies_parsed_at":"2022-09-04T03:22:07.600Z","dependency_job_id":null,"html_url":"https://github.com/nju33/context-modal","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nju33%2Fcontext-modal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nju33%2Fcontext-modal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nju33%2Fcontext-modal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nju33%2Fcontext-modal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nju33","download_url":"https://codeload.github.com/nju33/context-modal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235204562,"owners_count":18952331,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["context","dropdown","library","menu","modal","pure-javascript"],"created_at":"2024-11-22T12:13:19.170Z","updated_at":"2025-01-23T00:14:30.757Z","avatar_url":"https://github.com/nju33.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ContextModal\n\n\u003c!-- [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)\n\n[![Build Status](https://travis-ci.org/nju33/context-modal.svg?branch=master)](https://travis-ci.org/nju33/context-modal) --\u003e\n\nDisplay related elements with axis of trigger element. I made it to make it easy to make things like context-menu and dropdown, etc.\n\n\n![screenshot](https://github.com/nju33/context-modal/raw/master/images/screenshot.gif?raw=true)\n\n## Install or Download\n\n```sh\nyarn add context-modal\nnpm i -S context-modal\n```\n\nOr access to [releases page](https://github.com/nju33/context-modal/releases).\nThen, download the latest version.\n\n## Usage\n\nFirst, if you read as a separate file\n\n```html\n\u003cscript src=\"/path/tp/context-modal.js\"\u003e\u003c/script\u003e\n```\n\nMarkup is like this. (`test/fixtures/index.html`)\n\n```html\n\u003c!-- [data-context-modal-event-type=click] is default --\u003e\n\u003cdiv data-context-modal-for=\"menu\" data-context-modal-event-type=\"click\"\u003eButton\u003c/div\u003e\n\u003cdiv data-context-modal-id=\"menu\" style=\"display:none\"\u003e\n  \u003c!-- Your designed element --\u003e\n\u003c/div\u003e\n```\n\n`data-context-modal-for` works like `\u003clabel for\u003e`, `data-context-modal-id` works as `\u003cinput id\u003e`.\nThat is, `[data-context-modal-id=foo]` will be shown using something of `[data-context-modal-for=foo]` as a trigger.\n\nThe trigger is `click` by default, but you can change only that element by adding `data-context-modal-event-type`.\n\nAlso, by default, the top left of the modal comes to the position you clicked. If you want to fix this somewhere else (eg bottom-left), add `data-context-menu-offset` to `[data-context-menu-for]` element. The following values can be specified for this.\n\n- `left-top`\n- `left-bottom`\n- `right-top`\n- `right-bottom`\n\n```js\n// For es\nimport ContextModal from 'context-modal';\nconst ctxModal = new ContextModal(document.querySelectorAll('[data-context-modal-for]'), {\n  // This is global opts\n\n  // Elements to prevent scrolling while displaying\n  //\n  // Use `data-context-modal-scrollable`\n  // if you want to change only certain elements\n  scrollable: document.body,  // default\n\n  // Transition values at `onshow` and `onhide`\n  //\n  // Use `data-context-modal-transition-for-onshow` or `data-context-modal-transition-for-onhide`\n  // if you want to change only certain elements\n  transition: ['opacity .2s linear', 'none']  // defaults\n});\nctxModal.init();\n```\n\nAfter `ctxModal.init`, `[data-context-modal-id]` will be able to use the following events.\n\n- `contextmodalwillshow`  \n  Just before being shown\n- `contextmodaldidshow`  \n  After being shown (after transition)\n- `contextmodalwillhide`  \n  Just before hiding\n- `contextmodaldidhide`  \n  After hiding (after transition)\n\n### Example\n\n- `test/fixtures/index.js`\n- `example/webpack/index.js`\n\n## LICENSE\n\nThe MIT License (MIT)\n\nCopyright (c) 2017 nju33 \u003cnju33.ki@gmail.com\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnju33%2Fcontext-modal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnju33%2Fcontext-modal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnju33%2Fcontext-modal/lists"}