{"id":22191924,"url":"https://github.com/klich3/vue3-directives","last_synced_at":"2025-03-24T20:44:15.838Z","repository":{"id":252215480,"uuid":"839770799","full_name":"klich3/vue3-directives","owner":"klich3","description":"Compilation of directives that are quite helpful when programming projects, instead of searching by projects, they are gathered here.","archived":false,"fork":false,"pushed_at":"2024-08-14T13:39:05.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-30T01:17:17.215Z","etag":null,"topics":["direcitve","vue3","vue3-directives"],"latest_commit_sha":null,"homepage":"","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/klich3.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["klich3"],"ko_fi":"klich3","buy_me_a_coffee":"twooneone"}},"created_at":"2024-08-08T09:42:57.000Z","updated_at":"2024-08-14T13:39:08.000Z","dependencies_parsed_at":"2024-08-08T12:09:15.216Z","dependency_job_id":null,"html_url":"https://github.com/klich3/vue3-directives","commit_stats":null,"previous_names":["klich3/vue3-directives"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klich3%2Fvue3-directives","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klich3%2Fvue3-directives/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klich3%2Fvue3-directives/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klich3%2Fvue3-directives/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/klich3","download_url":"https://codeload.github.com/klich3/vue3-directives/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245351762,"owners_count":20601090,"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":["direcitve","vue3","vue3-directives"],"created_at":"2024-12-02T12:18:24.522Z","updated_at":"2025-03-24T20:44:15.811Z","avatar_url":"https://github.com/klich3.png","language":"JavaScript","funding_links":["https://github.com/sponsors/klich3","https://ko-fi.com/klich3","https://buymeacoffee.com/twooneone"],"categories":[],"sub_categories":[],"readme":"# VUE3 - Directives Library\n\nCompilation of directives that are quite helpful when programming projects, instead of searching by projects, they are gathered here.\n\n\n\n## clickOutsideClass\n\nDesc: Directive to detect click outside an element determined by class\n\n\n\n\u003cdetails\u003e\n    \u003csummary\u003eSample:\u003c/summary\u003e\n\n```javascript\nmain.js\nimport { setupClickOutsideClass } from \"@/directives/clickOutside\";\nsetupClickOutsideClass(app);\n\nor\n\nimport clickOutside from \"@/directives/clickOutside\";\napp.directive(\"click-outside-class\", clickOutside);\n```\n\n```html\ntemplate\n\u003cdiv v-click-outside-class=\"{ class: ['.menu', '.user-menu', '.user-wishlist'], handler: configuration.setCloseAllMenus }\"\u003e\n```\n\n\u003c/details\u003e\n\n## clickoutsideDirective\n\nDesc: Detect click outside of element\n\n\u003cdetails\u003e\n    \u003csummary\u003eSample:\u003c/summary\u003e\n\n```javascript\nmain.js:\n\n- auto\nimport { setupClickOutside } from \"@/directives/clickOutside\";\nsetupClickOutside(app);\n\n- manual\nimport clickoutsideDirective from \"@/directives/clickoutsideDirective\";\n\ndirectives: {\n    clickOutside: clickoutsideDirective,\n},\n\n- or \n\napp.directive(\"click-outside\", clickoutsideDirective);\n```\n\n```html\nhtml dom:\n\n\u003cdiv v-click-outside=\"onCampaingClickOutSide\"\u003e\u003cdiv\u003e\n```\n\u003c/details\u003e\n\n## contentFromSource\n\nDesc: This directive clones some DOM content to another element. It is useful for cloning a desktop menu to a mobile version or repeating content on a page.\n\nDocs: documentation\n\n\u003cdetails\u003e\n    \u003csummary\u003eSample:\u003c/summary\u003e\n\n```javascript\nmain.js:\n\nimport { setupFromSource } from \"contentFromSource.js\"\nsetupFromSource(app);\n\n- or manual\n\nimport contentFromSource from \"@/plugins/directives/contentFromSource.js\";\nVue.directive(\"from-source\", contentFromSource);\n```\n\n```html\ntemplate:\ndom: a DOM element like div, span, p, or a query selector like class -\u003e .class or #id\n\n\u003cdiv v-from-source=\"{ dom:'in-viewport', to:'.header' }\"\u003e\u003c/div\u003e\n\nIf \"to\" is specified, the clone will be placed inside that DOM element.\n```\n\u003c/details\u003e\n\n\n## onChangeDirective\n\nDesc: This directive triggers a callback function when a class is added to the element\n\n\u003cdetails\u003e\n    \u003csummary\u003eSample:\u003c/summary\u003e\n\n```javascript\nmain.js:\n\nimport { setupOnChange } from \"onChangeDirective.js\"\nsetupOnChange(app);\n\n- or manual\n\nimport onChangeDirective from \"@/plugins/directives/onChangeDirective.js\";\nVue.directive(\"onchange\", onChangeDirective);\n```\n\n```html\ntemplate:\nclass: when this class appears, it triggers the callback function\ndata: if needed, data can be passed to the callback function\n\n\u003cdiv v-onchange=\"{ class:'in-viewport', data: {} }\" @on-change=\"function_callback\"\u003e\u003c/div\u003e\n\nfunction_callback -\u003e attributes\nel -\u003e DOM element\ndata -\u003e parsed data\n```\n\u003c/details\u003e\n\n## observeVisibility\n\n\nDesc: directive observe-visibility for Vue 3\nDocs: \n\t* https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API\n\n\u003cdetails\u003e\n    \u003csummary\u003eSample:\u003c/summary\u003e\n\n```javascript\n    import { setupObserveVisibility } from \"@/directives/observe-visibility\";\n    setupObserveVisibility(app);\n```\n\n```html\n    tmeplate:\n    \u003cdiv v-observe-visibility=\"onVisibilityChange\"\u003e\u003c/div\u003e\n```\n\n```javascript\n\tconst changeClassOnVisible = (e, dom) =\u003e {\n\t\tconsole.log(e, e.domVisible, dom);\n\n\t\tif (e.domVisible) {\n\t\t\te.target.classList.add(\"visible\");\n\t\t\te.target.style.border = \"2px solid green\";\n\t\t\te.target.style.visibility = \"visible\";\n\t\t} else {\n\t\t\tdom.classList.remove(\"visible\");\n\t\t\tdom.style.border = \"none\";\n\t\t\tdom.style.visibility = \"hidden\";\n\t\t}\n\t};\n```\n\u003c/details\u003e\n\n\n## observeResize\n\nDesc: Observe resize directive\n\n\u003cdetails\u003e\n    \u003csummary\u003eSample:\u003c/summary\u003e\n```javascript\n    import { setupObserveResize } from \"@/directives/observe\n    setupObserveResize(app);\n```\n\n```html\n    tmeplate:\n    \u003cdiv v-observe-resize=\"doSomething\"\u003e\u003c/div\u003e\n```\n\n\u003c/details\u003e\n---\n\n## Star History\n\n[![Star History Chart](https://api.star-history.com/svg?repos=klich3/vue3-directives\u0026type=Date)](https://star-history.com/#klich3/vue3-directives\u0026Date)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklich3%2Fvue3-directives","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fklich3%2Fvue3-directives","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklich3%2Fvue3-directives/lists"}