{"id":20051936,"url":"https://github.com/sixem/hover-preview-js","last_synced_at":"2025-05-05T11:32:06.237Z","repository":{"id":42248823,"uuid":"171976068","full_name":"sixem/hover-preview-js","owner":"sixem","description":"Adds hoverable video and image previews to elements in Vanilla JS.","archived":false,"fork":false,"pushed_at":"2023-10-27T12:48:01.000Z","size":250,"stargazers_count":12,"open_issues_count":2,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-18T18:03:42.716Z","etag":null,"topics":["hover","hoverable","image","javascript","js","plugin","preview","previews","video"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/hover-preview-js","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/sixem.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-22T01:54:22.000Z","updated_at":"2025-04-15T12:20:40.000Z","dependencies_parsed_at":"2023-02-08T02:18:11.819Z","dependency_job_id":null,"html_url":"https://github.com/sixem/hover-preview-js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sixem%2Fhover-preview-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sixem%2Fhover-preview-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sixem%2Fhover-preview-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sixem%2Fhover-preview-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sixem","download_url":"https://codeload.github.com/sixem/hover-preview-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252489134,"owners_count":21756266,"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":["hover","hoverable","image","javascript","js","plugin","preview","previews","video"],"created_at":"2024-11-13T12:08:33.544Z","updated_at":"2025-05-05T11:32:05.867Z","avatar_url":"https://github.com/sixem.png","language":"JavaScript","readme":"# hover-preview-js\n\u003cimg alt=\"npm\" src=\"https://img.shields.io/npm/v/hover-preview-js?style=flat-square\"\u003e \u003cimg alt=\"Travis (.com)\" src=\"https://img.shields.io/travis/com/sixem/hover-preview-js?style=flat-square\"\u003e\n\nA simple plugin that adds hoverable image and video previews to any element.\n\n* No dependencies.\n* Browser, ES6 and CommonJS support.\n\nA demo of the script can be found [here](https://five.sh/demo/hover-preview/).\n\n## Usage\n\n### Install via npm\n`npm install hover-preview-js`\n\nor if using it directly in the browser:\n\n```html\n\u003cscript type=\"text/javascript\" src=\"./dist/hover-preview.min.js\"\u003e\u003c/script\u003e\n```\n### Include the script\n```javascript\n// CommonJS\nconst hoverPreview = require('hover-preview-js');\n\n// ES6\nimport hoverPreview from 'hover-preview-js';\n\n// if importing it as a \u003cscript\u003e in the browser\nconst hoverPreview = window.hoverPreview;\n```\n### Example Usage\nAn example element. The script will look for the preview URL in `data-src`, `src` and `href` in that order, or if a `source` option is passed, then that will take priority over everything else.\n```html\n\u003cdiv class=\"preview\" data-src=\"./DSCF3570sss_1.jpg\"\u003eDSCF3570sss_1.jpg (2,167 kB)\u003c/div\u003e\n```\nPass elements to the script.\n```javascript\n// apply it to a single element\nvar preview = hoverPreview(document.querySelector('div.preview'),\n{\n\tdelay : 100, // sets a delay before the preview is shown\n\tcursor : true // enables a loading cursor while the preview is loading\n});\n\n// apply it to multiple elements\nvar previews = [...document.querySelectorAll('.preview')].map((element, index) =\u003e\n{\n\treturn hoverPreview(element, {\n\t\tsource : `/image_${index}.jpg`\n\t});\n});\n\n// functions\npreview.reload(); // reloads the instance\npreview.destroy(); // removes all event listeners from the instance\n```\n\n## Options\n\n#### `source`\nSets the preview source directly. This will override any `data-src`, `src` and `href` attribute.\n##### Default: `null`\n\n#### `delay`\nEnables a hover delay (`ms`) before the preview is triggered.\n##### Default: `75`\n\n#### `cursor`\nAdds a temporary loading cursor while the preview is loading.\n##### Default: `true`\n\n#### `encodeAll`\nEncodes a few extra characters (`#` and `?`) when processing the URL.\n##### Default: `false`\n\n## License\n\nMIT License\n\nCopyright (c) 2020 ему (sixem)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsixem%2Fhover-preview-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsixem%2Fhover-preview-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsixem%2Fhover-preview-js/lists"}