{"id":13482101,"url":"https://github.com/1wheel/graph-scroll","last_synced_at":"2025-04-05T18:04:59.964Z","repository":{"id":25111386,"uuid":"28532791","full_name":"1wheel/graph-scroll","owner":"1wheel","description":"scrollers \u003e steppers ","archived":false,"fork":false,"pushed_at":"2020-03-21T23:38:05.000Z","size":538,"stargazers_count":514,"open_issues_count":2,"forks_count":50,"subscribers_count":12,"default_branch":"gh-pages","last_synced_at":"2025-03-29T17:13:45.493Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"HTML","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/1wheel.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":"2014-12-27T08:58:31.000Z","updated_at":"2025-02-12T05:48:08.000Z","dependencies_parsed_at":"2022-08-31T22:11:24.465Z","dependency_job_id":null,"html_url":"https://github.com/1wheel/graph-scroll","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/1wheel%2Fgraph-scroll","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1wheel%2Fgraph-scroll/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1wheel%2Fgraph-scroll/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1wheel%2Fgraph-scroll/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/1wheel","download_url":"https://codeload.github.com/1wheel/graph-scroll/tar.gz/refs/heads/gh-pages","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247378135,"owners_count":20929296,"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-07-31T17:00:58.971Z","updated_at":"2025-04-05T18:04:59.937Z","avatar_url":"https://github.com/1wheel.png","language":"HTML","funding_links":[],"categories":["HTML","Miscellaneous"],"sub_categories":[],"readme":"# graph-scroll.js\n\nSimple scrolling events for [d3](https://github.com/mbostock/d3) graphs. Based on [stack](https://github.com/mbostock/stack.git)\n\n### [Demo/Documentation](http://1wheel.github.io/graph-scroll/)\n\n*graph-scroll* takes a selection of explanatory text sections and dispatches `active` events as different sections are scrolled into to view. These `active` events can be used to update a chart's state.\n\n```\nd3.graphScroll()\n    .sections(d3.selectAll('#sections \u003e div'))\n    .on('active', function(i){ console.log(i + 'th section active') })\n```\n\nThe top most element scrolled fully into view is classed `graph-scroll-active`. This makes it easy to highlight the active section with css: \n\n```\n#sections \u003e div{\n\topacity: .3\n} \n\n#sections div.graph-scroll-active{\n\topacity: 1;\n}\n```\n\nTo support headers and intro images/text, we use a container element containing the explanatory text and graph.\n\n```\n\u003ch1\u003ePage Title\u003c/div\u003e\n\u003cdiv id='container'\u003e\n  \u003cdiv id='graph'\u003e\u003c/div\u003e\n  \u003cdiv id='sections'\u003e\n    \u003cdiv\u003eSection 0\u003c/div\u003e\n    \u003cdiv\u003eSection 1\u003c/div\u003e\n    \u003cdiv\u003eSection 2\u003c/div\u003e\n  \u003c/div\u003e\n\u003c/div\u003e\n\u003ch1\u003eFooter\u003c/h1\u003e\n```\n\nIf these elements are passed to graphScroll as selections with `container` and `graph`, every element in the graph selection will be classed `graph-scroll-graph` if the top of the container is out of view. \n\n```\nd3.graphScroll()\n\t.graph(d3.selectAll('#graph'))\n\t.container(d3.select('#container'))\n  .sections(d3.selectAll('#sections \u003e div'))\n  .on('active', function(i){ console.log(i + 'th section active') })\n\n```\n\nWhen the graph starts to scroll out of view, `position: sticky` keeps the graph element stuck to the top of the page while the text scrolls by.\n\n```\n#container{\n  position: relative;\n}\n\n#sections{\n  width: 340px;\n}\n\n#graph{\n  margin-left: 40px;\n  width: 500px;\n  position: sticky;\n  top: 0px;\n  float: right;\n}\n```\n\n\nOn mobile centering the graph and sections while adding a some padding for the first slide is a good option:\n\n```\n@media (max-width: 925px)  {\n  #graph{\n    width: 100%;\n    margin-left: 0px;\n    float: none;\n  }\n\n  #sections{\n    position: relative;\n    margin: 0px auto;\n    padding-top: 400px;\n  }\n}\n```\n\nAdjust the amount of pixels before a new section is triggered is also helpful on mobile (Defaults to 200 pixels):\n\n```\ngraphScroll.offset(300)\n```\n\nTo update or replace a graphScroll instance, pass a string to `eventId` to remove the old event listeners: \n\n```\ngraphScroll.eventId('uniqueId1')\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1wheel%2Fgraph-scroll","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F1wheel%2Fgraph-scroll","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1wheel%2Fgraph-scroll/lists"}