{"id":22404717,"url":"https://github.com/drewjbartlett/simple-breakpoints","last_synced_at":"2025-07-31T17:32:46.465Z","repository":{"id":46250310,"uuid":"75784681","full_name":"drewjbartlett/simple-breakpoints","owner":"drewjbartlett","description":"A simple breakpoints plugin based off of four simple breakpoint sizes ('mobile', 'tablet', 'small_desktop', 'large_desktop')","archived":false,"fork":false,"pushed_at":"2021-11-04T02:28:20.000Z","size":51,"stargazers_count":11,"open_issues_count":4,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-11T21:57:12.043Z","etag":null,"topics":["breakpoint","breakpoint-sizes","breakpoints-plugin","events","javascript"],"latest_commit_sha":null,"homepage":"","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/drewjbartlett.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":"2016-12-07T00:46:51.000Z","updated_at":"2023-04-18T04:49:57.000Z","dependencies_parsed_at":"2022-08-31T02:50:39.042Z","dependency_job_id":null,"html_url":"https://github.com/drewjbartlett/simple-breakpoints","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/drewjbartlett%2Fsimple-breakpoints","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drewjbartlett%2Fsimple-breakpoints/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drewjbartlett%2Fsimple-breakpoints/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drewjbartlett%2Fsimple-breakpoints/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drewjbartlett","download_url":"https://codeload.github.com/drewjbartlett/simple-breakpoints/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228275004,"owners_count":17895008,"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":["breakpoint","breakpoint-sizes","breakpoints-plugin","events","javascript"],"created_at":"2024-12-05T10:14:35.560Z","updated_at":"2024-12-05T10:14:36.168Z","avatar_url":"https://github.com/drewjbartlett.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Breakpoints\n\n[![npm](https://img.shields.io/npm/v/simple-breakpoints.svg)](https://www.npmjs.com/package/simple-breakpoints)\n[![npm](https://img.shields.io/npm/dt/simple-breakpoints.svg)](https://www.npmjs.com/package/simple-breakpoints)\n\n_A simple breakpoints plugin based off of four simple breakpoint sizes (`'mobile', 'tablet', 'small_desktop', 'large_desktop'`) with support to listen for breakpoint change events_\n\n## Installation and usage\n\n    $ npm install simple-breakpoints --save\n\n```javascript\n    import SimpleBreakpoints from 'simple-breakpoints'\n\n    // default breakpoint sizes: { mobile: 480, tablet: 640, small_desktop: 1024, large_desktop: 1180 }\n    var breakpoints = new SimpleBreakpoints();\n\n    if(breakpoints.isMobile()) {\n        // do something for mobile\n    }\n\n    if(breakpoints.isSmallDesktop()) {\n        // do something for small desktop\n    }\n\n    if(breakpoints.isBetween('small_desktop', 'large_desktop')) {\n        // do something between small and large desktop\n    }\n\n```\n\n### Listening to events\n\n```javascript\n    // on all breakpoint changes\n    breakpoints.on('breakpointChange', (from, to) =\u003e {\n        console.log(`change from ${from} to ${to}`);\n        // change from small_desktop to large_desktop\n        // change from tablet to mobile\n    });\n\n    // on breakpoint changes from small to large\n    breakpoints.on('breakpointChangeUp', (from, to) =\u003e {\n        console.log(`change Up from ${from} to ${to}`);\n        // change from small_desktop to large_desktop\n    });\n\n    // on breakpoint changes from large to small\n    breakpoints.on('breakpointChangeDown', (from, to) =\u003e {\n        console.log(`change Down from ${from} to ${to}`);\n        // change from large_desktop to small_desktop\n    });\n\n    // remove all events from `breakpointChangeDown`\n    breakpoints.off('breakpointChangeDown');\n\n    // fire an event only once\n    breakpoints.once('breakpointChange', (from, to) =\u003e {\n        console.log(`firing an event ${from} to ${to} only once`);\n        // change from large_desktop to small_desktop\n    });\n\n```\n\n### Defining your own breakpoints\n\n```javascript\n    import SimpleBreakpoints from 'simple-breakpoints'\n\n    var breakpoints = new SimpleBreakpoints({\n        mobile        : 320,\n        tablet        : 640,\n        small_desktop : 900,\n        large_desktop : 1200\n    });\n\n```\n\n### API\n\nFunction | Params | Description\n------ | -------- | -----------\ngetViewportSize |  | returns the viewport size as object `{ width: 1024, height: 768 }` _this is fired on `window.resize` and is stored in `breakpoints.viewport`_\ncurrentBreakpoint | | returns current breakpoint size (`'mobile', 'tablet', 'small_desktop', 'large_desktop'`)\nisBetween | smallBreakpoint, largeBreakpoint (`'mobile', 'tablet', 'small_desktop', 'large_desktop'`) | Check if viewport is between two breakpoints\nisLessThan | breakpoint (`'mobile', 'tablet', 'small_desktop', 'large_desktop'`) | Check if viewport is less than the width of the breakpoint\nisGreaterThan | breakpoint (`'mobile', 'tablet', 'small_desktop', 'large_desktop'`) | Check if viewport is greater than the width of the breakpoint\nisLessThanEqualTo | breakpoint (`'mobile', 'tablet', 'small_desktop', 'large_desktop'`) | Check if viewport is less than or equal the width of the breakpoint\nisGreaterThanEqualTo | breakpoint (`'mobile', 'tablet', 'small_desktop', 'large_desktop'`) | Check if viewport is greater than or equal the width of the breakpoint\nisMobile | | Check if the viewport is within the `mobile` breakpoint\nisTablet | | Check if the viewport is within the `tablet` breakpoint\nisSmallDesktop | | Check if the viewport is within the `small_desktop` breakpoint\nisLargeDesktop | | Check if the viewport is within the `large_desktop` breakpoint\non (event, callback) | (`'breakpointChange' | 'breakpointChangeUp' | 'breakpointChangeDown'`, `callback(from, to)`) | watch for changes on breakpoints with and fire a callback\nonce (event, callback) | (`'breakpointChange' | 'breakpointChangeUp' | 'breakpointChangeDown'`, `callback(from, to)`) | watch for changes on breakpoints with and fire a callback only *once*\noff (event) | (`'breakpointChange' | 'breakpointChangeUp' |  'breakpointChangeDown'`)| Remove event listener for breakpoint change\n\n### For using with [Vue.js](https://vuejs.org/), see [vue-simple-breakpoints](https://github.com/drewjbartlett/vue-simple-breakpoints)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrewjbartlett%2Fsimple-breakpoints","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrewjbartlett%2Fsimple-breakpoints","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrewjbartlett%2Fsimple-breakpoints/lists"}