{"id":23744978,"url":"https://github.com/wheeyls/flocus","last_synced_at":"2025-07-12T04:35:32.306Z","repository":{"id":7337215,"uuid":"8659916","full_name":"wheeyls/flocus","owner":"wheeyls","description":null,"archived":false,"fork":false,"pushed_at":"2013-03-10T23:00:02.000Z","size":188,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-22T06:06:25.093Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wheeyls.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":"2013-03-08T21:10:00.000Z","updated_at":"2013-10-11T17:12:14.000Z","dependencies_parsed_at":"2022-09-01T15:42:02.036Z","dependency_job_id":null,"html_url":"https://github.com/wheeyls/flocus","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wheeyls/flocus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wheeyls%2Fflocus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wheeyls%2Fflocus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wheeyls%2Fflocus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wheeyls%2Fflocus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wheeyls","download_url":"https://codeload.github.com/wheeyls/flocus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wheeyls%2Fflocus/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261244053,"owners_count":23129642,"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-31T12:51:43.801Z","updated_at":"2025-06-22T06:06:30.554Z","avatar_url":"https://github.com/wheeyls.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Flocus\n------\nFlocus is a simple state-machine with hooks for building web interactions.\n\nIt was originally designed to build a step-by-step wizard. It is also pretty good at rapidly mocking up interfaces.\n\nThe chainable API allows you to describe a number of different states that the page will transition between.\n\nGive each state a name and describe their setup and teardown behavior. Then create events that transition between the diffent states.\nThere are some built in shortcuts around the \"next\" and \"previous\" events.\n\nExample\n-------\n    flocus\n    .add('loggedOut', {\n      events: {\n        login: 'loggedIn'\n      }\n    , addClasses: [['.selector', 'classes-to-add when-entering']]\n    , removeClasses: [['.selector', 'classes-to-remove when-entering']]\n    , enter: function () { /* run when entering this state */ }\n    })\n    .add('loggedIn', {\n      events: {\n        logout: 'loggedOut'\n      }\n    , addClasses: [['.selector', 'classes-to-add when-entering']]\n    , removeClasses: [['.selector', 'classes-to-remove when-entering']]\n    , leave: function () { /* run when leaving this state */ }\n    })\n    .begin('loggedOut');\n\nYou can also see a working demo at https://rawgithub.com/wheeyls/flocus/master/index.html\n\nChanging State\n--------------\nCalling ```flocus.next()``` and ```flocus.previous()``` will crawl through the states in order.\n\nCalling ```flocus.perform('eventName')``` will change state based on the named event.\n\nCalling ```flocus.setState('stateName')``` can be used to force the state directly.\n\nChanging the state will trigger the custom event ```'flocus:state-change'```.\n\nNext and Previous\n-----------------\nFlocus looks for the classes .js-next-state and .js-previous-state on begin, and will bind the next and previous events to the click on these elements. This allows an easy way to move through the different states.\n\nBegin\n-----\nCalling ```flocus.begin('stateName')``` will kick everything into motion, entering the given state, and activating all listeners.\n\nBookmarklet\n-----------\nFlocus comes with a bookmarklet that creates an overlay to help to visualize and navigate through the different states on the page.\n\njQuery/Zepto/ender?\n-------------------\nYep.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwheeyls%2Fflocus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwheeyls%2Fflocus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwheeyls%2Fflocus/lists"}