{"id":28403528,"url":"https://github.com/usablica/kissui.position","last_synced_at":"2025-06-27T08:32:22.441Z","repository":{"id":57146222,"uuid":"63528997","full_name":"usablica/kissui.position","owner":"usablica","description":"Track element(s) on the page like a boss.","archived":false,"fork":false,"pushed_at":"2016-09-25T09:17:31.000Z","size":25,"stargazers_count":23,"open_issues_count":1,"forks_count":4,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-06-08T16:43:14.740Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://usablica.github.io/kissui.position/","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/usablica.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":"2016-07-17T11:40:39.000Z","updated_at":"2024-03-10T08:43:47.000Z","dependencies_parsed_at":"2022-09-05T14:01:57.661Z","dependency_job_id":null,"html_url":"https://github.com/usablica/kissui.position","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/usablica/kissui.position","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usablica%2Fkissui.position","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usablica%2Fkissui.position/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usablica%2Fkissui.position/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usablica%2Fkissui.position/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/usablica","download_url":"https://codeload.github.com/usablica/kissui.position/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usablica%2Fkissui.position/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262222564,"owners_count":23277459,"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":[],"created_at":"2025-06-01T18:07:40.559Z","updated_at":"2025-06-27T08:32:22.429Z","avatar_url":"https://github.com/usablica.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kissui.position\nTrack element(s) on the page like a boss.\n\nThis library is a part of Kissui project.\n\n# Install\n\nYou can use *NPM* or *Bower* or *download the package manually*.\n\n# Getting Started\n\nUsing this libarary is as easy as adding `data-kui-position` attribute to your elements:\n\n```html\n\u003cp data-kui-position=\"in\"\u003e\u003c/p\u003e\n```\n\nand then bind an event listener:\n\n```js\nkissuiPosition.on ('in', function (element) {\n  console.log('yay!', element);\n});\n```\n\nand to init the library, call this before `\u003c/body\u003e`:\n\n```js\nkissuiPosition.init();\n```\n\nThat's it. \n\n# Events\n\nHere is a list of available events:\n\n- `in` - when element is in the viewport\n- `out` - when element is not in the viewport\n- `middle` - center aligned element (vertically)\n- `center` - center aligned element (horizontally)\n- `top` - element at the top of the page\n- `bottom` - elemennt at the bottom of the page\n- `left` - element at the left side of the page\n- `right` - element at the right side of the page\n- `partially` - with one only works with `out` event, e.g. `partially out` and it means when the element is partially out of the element (e.g. half of the height or width)\n\nAlso, it is possible to use a compond of events together. \n\n**Example:**  \n\nElement is in the viewport and center of the page:\n\n```html\n\u003cp data-kui-position=\"in center\"\u003e\u003c/p\u003e\n```\n\nElement is located in the center and middle of the page:\n\n```html\n\u003cp data-kui-position=\"in middle center\"\u003e\u003c/p\u003e\n```\n\n# EventListener\n\nIt is possible to listen to events and catch them using following methods.\n\n## ID-based event\n\nYou can get the events of an element using its ID. Let's say you have:\n\n```html\n\u003cp id=\"paragraph\" data-kui-position=\"in right\"\u003eThis element is tracking by Kissui.Position\u003c/p\u003e\n```\n\nthen you can get events using:\n\n```js\nkissuiPosition.on('paragraph', function (element) {\n  console.log('with id', element);\n});\n```\n\n## * event\n\nIf you want to get all events, simply bind a callback function to `*` event:\n\n```js\nkissuiPosition.on('*', function (element, event) {\n  console.log('*', element, event);\n});\n```\n\n## position event\n\nAlso, you can get all events using its unique `data-kui-position` attribute value. So, imagine you have:\n\n```html\n\u003cp id=\"paragraph\" data-kui-position=\"in right\"\u003ethis element is tracking by kissui.position\u003c/p\u003e\n```\n\nthen you can listen to events from `in right` (with the same order):\n\n```js\nkissuiPosition.on('in right', function (element) {\n  console.log('single', element);\n});\n```\n\n## TODOs\n\n- The combination of `out` and other events are not completely implemented. now it works with `top` only, e.g. `out top`. we should implement other positions as well.\n- Unit testing\n\nWhat to help? I have a look at the TODO list and send a PR, cheers.\n\n# Author\nAfshin Mehrabani\n\n# License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fusablica%2Fkissui.position","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fusablica%2Fkissui.position","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fusablica%2Fkissui.position/lists"}