{"id":17508196,"url":"https://github.com/shira-374/jquery-scrollwatch","last_synced_at":"2025-08-24T10:13:10.991Z","repository":{"id":8250548,"uuid":"9697398","full_name":"shira-374/jquery-scrollwatch","owner":"shira-374","description":"jQuery plugin for determining active sections on the page based on scrolling","archived":false,"fork":false,"pushed_at":"2024-12-20T10:23:14.000Z","size":67,"stargazers_count":17,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-11T03:31:12.481Z","etag":null,"topics":["active","class","javascript","jquery","navigation","scrolling"],"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/shira-374.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","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":"2013-04-26T14:40:30.000Z","updated_at":"2024-12-20T10:23:17.000Z","dependencies_parsed_at":"2024-12-20T11:26:20.060Z","dependency_job_id":"f6b2c645-2ba8-4ddf-80b9-8eb7b04634b6","html_url":"https://github.com/shira-374/jquery-scrollwatch","commit_stats":null,"previous_names":["shiranai7/jquery-scrollwatch","shira-374/jquery-scrollwatch"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shira-374%2Fjquery-scrollwatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shira-374%2Fjquery-scrollwatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shira-374%2Fjquery-scrollwatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shira-374%2Fjquery-scrollwatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shira-374","download_url":"https://codeload.github.com/shira-374/jquery-scrollwatch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250435035,"owners_count":21430207,"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":["active","class","javascript","jquery","navigation","scrolling"],"created_at":"2024-10-20T04:12:45.697Z","updated_at":"2025-04-23T12:33:27.024Z","avatar_url":"https://github.com/shira-374.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"ScrollWatch\n###########\n\njQuery plugin for determining active sections on the page based on scrolling.\n\n`Online demo (latest version) \u003chttps://raw.githack.com/shira-374/jquery-scrollwatch/master/demo.html\u003e`_\n\n.. contents::\n   :depth: 2\n\n\nFeatures\n********\n\n- determining active section(s)\n- mapping a class to a list of elements (e.g. menu items)\n- many options, including multiple modes of resolution\n- works with zoom\n\n\nRequirements\n************\n\njQuery 1.9.0 or newer\n\n\nUsage\n*****\n\nThe plugin provides two jQuery methods:\n\n.. NOTE::\n\n   If the sections are inside a custom scrollable element, that element **must** have\n   ``position: relative``, ``absolute`` or ``fixed``.\n\n\n``$(sections).scrollWatch(callback[, options])``\n================================================\n\nAttaches a watcher to the given sections. The callback is then invoked when the focus changes, according to options.\n\n- ``sections`` - selector or an array of elements that represent all the possible sections\n- ``callback`` - function to invoke when the focus changes\n- ``options`` - object with various settings (see list far below)\n\n\nCallback arguments\n------------------\n\n.. code:: javascript\n\n   $('div.section').scrollWatch(function (focus, view, watcher) {\n       // do something with the current focus\n   });\n\n\n1. | ``Object|Object[] focus`` - the current focus, an object with the following properties:\n   | (if ``resolutionMode`` is ``none``, it will be an array of those objects\n\n   - ``index`` - section number (0-based)\n   - ``intersection`` - ``null`` or ``[y1, y2]``\n   - ``section`` - DOM element of the section\n\n2. ``Object view`` - the current view, an object with the following properties:\n\n   - ``top`` - top coordinate of the view\n   - ``bottom`` - bottom coordinate of the view\n\n3. ``Shira.ScrollWatch.Watcher watcher`` - instance of the current watcher\n\n\n``$(sections).scrollWatchMapTo(items[, activeClass, options])``\n===============================================================\n\nAttaches a watcher to the given sections and maps the current focus to the respective\nitem using the specified *active class*.\n\n- ``sections`` - selector or an array of elements that represent all the possible sections\n- ``items`` - selector or an array of elements to map the \"active class\" to\n- ``activeClass`` - class name to add to the active item (defaults to ``\"active\"``)\n- ``options`` - object with various settings (see list far below)\n\n\nExample\n-------\n\n.. code:: javascript\n\n   $('div.section').scrollWatchMapTo('#menu \u003e li');\n\n\nList of supported options\n=========================\n\n====================== ================== ========================================================\nOption                 Default            Description\n====================== ================== ========================================================\n``scroller``           ``null``           DOM element to watch for scrolling events.\n\n                                          It must be an ``HTMLElement`` or ``Window``.\n\n                                          If no element is given the first found scrollable\n                                          offset parent or ``Window`` will be used instead.\n---------------------- ------------------ --------------------------------------------------------\n``resolutionMode``     ``\"height\"``       Determines how the active section is chosen,\n                                          one of:\n\n                                          - ``height`` - section that is occupying the largest\n                                            portion of the view is chosen\n                                          - ``focus-line`` - section that is directly intersecting\n                                            or is closest to the focus line is chosen\n                                          - ``custom`` - use a custom resolver\n                                          - ``none`` - no resolution is performed (all candidates\n                                            will be passed to the callback)\n---------------------- ------------------ --------------------------------------------------------\n``viewMarginTop``      ``0``              Height of an area at the top of the view to be excluded.\n---------------------- ------------------ --------------------------------------------------------\n``viewMarginBottom``   ``0``              Height of an area at the bottom of the view to be\n                                          excluded.\n---------------------- ------------------ --------------------------------------------------------\n``stickyOffsetTop``    ``5``              Height of an area at the top of the scroller that, if\n                                          intersected by the top of the view, forces the first\n                                          section to be active regardless of other conditions.\n---------------------- ------------------ --------------------------------------------------------\n``stickyOffsetBottom`` ``5``              Height of an area at the bottom of the scroller that, if\n                                          intersected by the bottom of the view, forces the last\n                                          section to be active regardless of other conditions.\n---------------------- ------------------ --------------------------------------------------------\n``clamp``              ``false``          When enabled, the space between two sections is\n                                          considered a part of the first section. Useful when\n                                          there are large gaps between sections.\n---------------------- ------------------ --------------------------------------------------------\n``throttle``           ``true``           When enabled, the callback is invoked only when the\n                                          active section changes\n\n                                          When disabled, the callback is invoked on every pulse\n                                          (e.g. on scroll and resize).\n\n                                          This option has no effect when ``resolutionMode`` is\n                                          ``none``.\n====================== ================== ========================================================\n\n\nOptions specific to ``resolutionMode`` = ``height``\n---------------------------------------------------\n\n====================== ================== ========================================================\nOption                 Default            Description\n====================== ================== ========================================================\n``topDownWeight``      ``0``              Extra focus height added to the section if it precedes\n                                          the other. This can be used to prefer earlier sections\n                                          to later ones.\n---------------------- ------------------ --------------------------------------------------------\n====================== ================== ========================================================\n\n\nOptions for ``resolutionMode`` = ``focus-line``\n-----------------------------------------------\n\n====================== ================== ========================================================\nOption                 Default            Description\n====================== ================== ========================================================\n``focusRatio``         ``0.3819..``       Percentage of the view height that determines position\n                                          of the focus line.\n---------------------- ------------------ --------------------------------------------------------\n``focusOffset``        ``0``              Offset added to position of the focus line position\n                                          after ``focusRatio`` is applied.\n\n                                          Set ``focusRatio`` to ``0`` if you wish to use the\n                                          ``focusOffset`` as an absolute value.\n---------------------- ------------------ --------------------------------------------------------\n``debugFocusLine``     ``false``          When enabled, position of the focus line will be\n                                          displayed when scrolling\n\n                                          Intended for debugging purposes.\n====================== ================== ========================================================\n\n\nOptions for ``resolutionMode`` = ``custom``\n-------------------------------------------\n\n====================== ================== ========================================================\nOption                 Default            Description\n====================== ================== ========================================================\n``resolver``           none (required)    Function to invoke when a focus candidate resolution is\n                                          needed. It must choose and return a single focus object.\n\n                                          The following arguments are passed to the function:\n\n                                          1. ``Object[] candidates`` - an array of focus objects,\n                                             each object has the following properties:\n\n                                             - ``index`` - section number (0-based)\n                                             - ``intersection`` - ``null`` or ``[y1, y2]``\n                                             - ``section`` - DOM element of the section\n====================== ================== ========================================================\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshira-374%2Fjquery-scrollwatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshira-374%2Fjquery-scrollwatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshira-374%2Fjquery-scrollwatch/lists"}