{"id":15434305,"url":"https://github.com/cenfun/popover-helper","last_synced_at":"2025-03-14T14:15:04.178Z","repository":{"id":53628933,"uuid":"281306400","full_name":"cenfun/popover-helper","owner":"cenfun","description":"popover-helper","archived":false,"fork":false,"pushed_at":"2023-03-30T07:12:22.000Z","size":85,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-10-18T08:39:23.607Z","etag":null,"topics":["algorithm","popover"],"latest_commit_sha":null,"homepage":"https://cenfun.github.io/popover-helper","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/cenfun.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-21T05:43:40.000Z","updated_at":"2022-08-05T06:00:56.000Z","dependencies_parsed_at":"2024-10-20T20:33:00.845Z","dependency_job_id":null,"html_url":"https://github.com/cenfun/popover-helper","commit_stats":{"total_commits":42,"total_committers":2,"mean_commits":21.0,"dds":"0.38095238095238093","last_synced_commit":"0129c40172c6888f43bc30a978dfa51d57abd3f7"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cenfun%2Fpopover-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cenfun%2Fpopover-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cenfun%2Fpopover-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cenfun%2Fpopover-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cenfun","download_url":"https://codeload.github.com/cenfun/popover-helper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243589328,"owners_count":20315471,"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":["algorithm","popover"],"created_at":"2024-10-01T18:38:44.795Z","updated_at":"2025-03-14T14:15:04.149Z","avatar_url":"https://github.com/cenfun.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Popover Helper\n## Preview\n[https://cenfun.github.io/popover-helper](https://cenfun.github.io/popover-helper)\n\n## Install\n```sh\nnpm i popover-helper\n```\n\n## Usage\n```js\nimport { getRect, getBestPosition, getPositionStyle } from \"popover-helper\";\n\nconst $popover = document.querySelector('.popover');\nlet positionInfo;\n\nconst update = () =\u003e {\n    //get 3 rect for calculation\n    const containerRect = getRect('.container');\n    const targetRect = getRect('.target');\n    const popoverRect = getRect('.popover');\n    const positions = [];\n\n    positionInfo = getBestPosition(\n        containerRect,\n        targetRect,\n        popoverRect,\n        //allowed positions\n        positions,\n        //previous position info\n        positionInfo\n    );\n\n    //console.log(positionInfo);\n    if (positionInfo.changed) {\n        $popover.style.left = `${positionInfo.left}px`;\n        $popover.style.top = `${positionInfo.top}px`;\n    }\n\n    const style = getPositionStyle(positionInfo, {\n        bgColor: \"#fff\",\n        borderColor: \"#ccc\",\n        arrowSize: 10\n    });\n    // performance optimized\n    if (style.changed) {\n        $popover.style.background = style.background;\n    }\n};\n\nupdate();\n\n```\nsee [/public/index.html](/public/index.html)\n\n## CHANGELOG\n\n- 2.0.5\n    - added argument `fixed` for `getRect(target, fixed)`\n\n- 2.0.4\n    - fixed arrow size (#1)\n\n- 2.0.3\n    - fixed performance issue\n\n- 2.0.0\n    - replaced css arrow with svg background\n\n- 1.0.3\n    - added color to css\n    - fixed positions sort issue","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcenfun%2Fpopover-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcenfun%2Fpopover-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcenfun%2Fpopover-helper/lists"}