{"id":22356841,"url":"https://github.com/ayamflow/windowsill","last_synced_at":"2025-07-30T10:32:37.971Z","repository":{"id":22430377,"uuid":"25768368","full_name":"ayamflow/windowsill","owner":"ayamflow","description":"Abstracted, debounced windows events.","archived":false,"fork":false,"pushed_at":"2015-04-02T18:00:28.000Z","size":188,"stargazers_count":13,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-18T21:02:48.065Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ayamflow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-26T11:06:05.000Z","updated_at":"2022-08-11T14:03:32.000Z","dependencies_parsed_at":"2022-08-21T06:30:37.894Z","dependency_job_id":null,"html_url":"https://github.com/ayamflow/windowsill","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayamflow%2Fwindowsill","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayamflow%2Fwindowsill/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayamflow%2Fwindowsill/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayamflow%2Fwindowsill/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ayamflow","download_url":"https://codeload.github.com/ayamflow/windowsill/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228124602,"owners_count":17873170,"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":"2024-12-04T14:12:11.404Z","updated_at":"2024-12-04T14:12:11.952Z","avatar_url":"https://github.com/ayamflow.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"windowsill\n====\n\nAbstract, debounced windows events.\nAllow you to listen to an event emitter rather than to the DOM.\n\n\n## Installation\n`npm i windowsill --save`\n\n`component install ayamflow/windowsill`\n\n## API\n### windowsill(event, opts)\nFactory returning a sill object (event emitter responding to the provided `event`).\n* event: a string-based window event, such as 'scroll', 'resize', ...\n* opts:\n    * *debounce*: debounce delay for the event\n    * *props*: hash of window properties to inherit (see example)\n    * *beforeEvent*: callback called before emitting the event\n    * *afterEvent*: callback called after emitting the event\n\n### windowsill.enable(sillName)\nBind the requested sill on window. (available for `resizer` and `scroller`).\n*Since sill object are deactivated by default, you have to call this method to enable `resizer` and `scroller`.*\n\n### windowsill.disable(sillName)\nUnbind the requested sill.\n\n### sill object API\n* *addListener(cb)*\n* *removeListener(cb)*\n* *bind*: attach the event to the DOM\n* *unbind*: detach the event from the DOM \u0026 remove all listeners from the sill object\n* *onEvent(event)*: manually trigger the sill update. You can pass an event-like object if you want to set some properties, or just let it parse (if possible) those properties from the `window` object.\n\n### Example\n\n```\nvar scroller = windowsill('scroll', {\n    debounce: 50,\n    props: {\n        x: 'pageXOffset', // (1)\n        y: 'pageYOffset',\n        dx: 0, // (2)\n        dy: 0,\n        ox: 0,\n        oy: 0,\n        beforeEvent: function(sill, event) { // (3)\n            sill.ox = sill.x;\n            sill.oy = sill.y;\n        },\n        afterEvent: function(sill, event) {\n            sill.dx = sill.x - sill.ox;\n            sill.dy = sill.y - sill.oy;\n        }\n    }\n});\n\nscroller.addListener(this.onScroll);\nscroller.onEvent();\n\nscroller.unbind(); // unbind event from window \u0026 clear all listeners.\n```\n\n* *(1)* you can link a window property to the sill object by passing it as a string. `scroller.x` will be set to `window.pageXOffset` on each event.\n* *(2)* you can also pass additionnal properties as non-string, mostly to give initial values.\n* *(3)* you can pass `beforeEvent` and `afterEvent` callbacks, which will be called respectively before and after the event is emitted. The sill reference and the event are passed as parameters to those callbacks.\n\nBy default, `scroll` and `resize` are already available as `windowsill.resizer` and `windowsill.scroller`, with default debounce time (see [events.js](https://github.com/ayamflow/windowsill/blob/master/src/events.js) for more details).\nThis allows to bind all window events to a global abstract object:\n\n```\nvar windowsill = require('windowsill'),\n    resizer = windowsill.resizer;\n\nresizer.addListener(function(event) {\n    console.log('resize event', event);\n});\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayamflow%2Fwindowsill","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fayamflow%2Fwindowsill","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayamflow%2Fwindowsill/lists"}