{"id":23156513,"url":"https://github.com/thecreation/breakpoints-js","last_synced_at":"2025-12-12T03:50:35.744Z","repository":{"id":30436792,"uuid":"33989870","full_name":"thecreation/breakpoints-js","owner":"thecreation","description":"Awesome Breakpoints in JavaScript. (bootstrap supported)","archived":false,"fork":false,"pushed_at":"2018-09-12T07:44:56.000Z","size":230,"stargazers_count":76,"open_issues_count":1,"forks_count":30,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-23T12:41:21.379Z","etag":null,"topics":["breakpoints","javascript","responsive"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thecreation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-15T11:26:56.000Z","updated_at":"2025-02-16T13:39:48.000Z","dependencies_parsed_at":"2022-08-30T20:10:43.716Z","dependency_job_id":null,"html_url":"https://github.com/thecreation/breakpoints-js","commit_stats":null,"previous_names":["amazingsurge/breakpoints-js","amazingsurge/breakpoints.js"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecreation%2Fbreakpoints-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecreation%2Fbreakpoints-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecreation%2Fbreakpoints-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecreation%2Fbreakpoints-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thecreation","download_url":"https://codeload.github.com/thecreation/breakpoints-js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecreation%2Fbreakpoints-js/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259072699,"owners_count":22801069,"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":["breakpoints","javascript","responsive"],"created_at":"2024-12-17T21:13:52.975Z","updated_at":"2025-10-09T20:17:02.093Z","avatar_url":"https://github.com/thecreation.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [breakpoints-js](https://github.com/amazingSurge/breakpoints-js) ![bower][bower-image] [![NPM version][npm-image]][npm-url] [![Dependency Status][daviddm-image]][daviddm-url] [![prs-welcome]](#contributing)\n\n\u003e `breakpoints-js` is a lightweight, pure javascript library for attaching callbacks to breakpoints. \n\n## Table of contents\n- [Main files](#main-files)\n- [Quick start](#quick-start)\n- [Usage](#usage)\n- [Examples](#examples)\n- [Defaults](#defaults)\n- [Methods](#methods)\n- [Browser support](#browser-support)\n- [Contributing](#contributing)\n- [Development](#development)\n- [Changelog](#changelog)\n- [Other Projects](#other-projects)\n- [Copyright and license](#copyright-and-license)\n\n## Main files\n```\ndist/\n├── breakpoints.js\n├── breakpoints.es.js\n└── breakpoints.min.js\n```\n## Quick start\nDownload the [production version][min] or the [development version][max].\n\n[min]: https://raw.github.com/amazingSurge/breakpoints-js/master/dist/breakpoints.min.js\n[max]: https://raw.github.com/amazingSurge/breakpoints-js/master/dist/breakpoints.js\n\n#### Install From Bower\n```sh\nbower install breakpoints.js --save\n```\n\n#### Install From Npm\n```sh\nnpm install breakpoints-js --save\n```\n\n#### Install From Yarn\n```sh\nyarn add breakpoints-js\n```\n\n###Build From Source\n\nIf you want build from source:\n\n```sh\ngit clone git@github.com:amazingSurge/breakpoints-js.git\ncd breakpoints-js\nnpm install\nnpm install -g gulp-cli babel-cli\ngulp build\n```\n\nDone!\n\n## Usage\n\nBefore you try anything, you need to include breakpoints.js in your page.\n\n```html\n\u003cscript src=\"breakpoints.min.js\"\u003e\u003c/script\u003e\n```\n\nYou may need provide a matchMedia polyfill if you wish to [support old/incapable browsers](#browser-support).\n\nThen you can init the script easily by code \n```javascript\n\u003cscript type=\"text/javascript\"\u003e\n    Breakpoints();\n\u003c/script\u003e\n```\n\n## Examples\nThere are some example usages that you can look at to get started. They can be found in the\n[examples folder](https://github.com/amazingSurge/breakpoints-js/tree/master/examples).\n\n## Defaults\nIt will use the bootstrap media query breakpoints by default:\n\n```javascript\nBreakpoints.defaults = {\n    // Extra small devices (phones)\n    xs: {\n        min: 0,\n        max: 767\n    },\n    // Small devices (tablets)\n    sm: {\n        min: 768,\n        max: 991\n    },\n    // Medium devices (desktops)\n    md: {\n        min: 992,\n        max: 1199,\n    },\n    // Large devices (large desktops)\n    lg: {\n        min: 1200,\n        max: Infinity\n    }\n};\n```\n\nYou can set up your own breakpoints when initialize it:\n\n```javascript\n\u003cscript type=\"text/javascript\"\u003e\n    Breakpoints({\n        mobile: {\n            min: 0,\n            max: 767\n        },\n        tablet: {\n            min: 768,\n            max: 991\n        },\n        destop: {\n            min: 992,\n            max: Infinity\n        }\n    });\n\u003c/script\u003e\n```\n\n## Methods\n### is\n\nCheck if the current screen is a specific size.\n\n```javascript\nBreakpoints.is('xs'); // return true or false\n```\n\n### get\nReturn the size object that you can operate it handily.\n\n```javascript\n// get size object\nvar sm = Breakpoints.get('sm');\n\n// attach events\nsm.on('enter', function(){\n    // do something\n});\n\n// remove event handler\nsm.off('enter');\n\n// get min width\nsm.min // 768\n\n// get max width\nsm.max // 991\n\n// get media query\nsm.media // \"(min-width: 768px) and (max-width: 991px)\"\n\n// check if it's current size\nsm.isMatched(); // true or false\n\n// you can do in a chain\nBreakpoints.get('sm').on({\n    enter: function(){\n\n    },\n    leave: function(){\n\n    }\n});\n```\n\n### current\nReturn the current screen size object\n\n```javascript\nBreakpoints.current();\n```\n\n### on\nAttach an event handler function for one or more events to the size\n\n```javascript\nBreakpoints.on('md', {\n    enter: function() {\n        console.info('enter '+ this.name);\n    },\n    leave: function() {\n        console.info('leave '+ this.name);\n    }\n});\n\nBreakpoints.on('lg', 'enter', function(){\n    console.info('hello lg');\n});\n```\n\n#### Passing data to the callback\n\n```javascript\nBreakpoints.on('sm', \"enter\", {\n    name: \"Addy\"\n}, function(data) {\n    console.info(data.name + ' enter '+ this.name);\n});\n\nBreakpoints.on('sm', \"leave\", {\n    name: \"Karl\"\n}, function(data) {\n    console.info(data.name + ' leave '+ this.name);\n});\n```\n\n#### Unite sizes\n\n```javascript\nBreakpoints.on('md lg', {\n    enter: function() {\n        console.info('enter '+ this.name);\n    },\n    leave: function() {\n        console.info('leave '+ this.name);\n    }\n});\n```\n\n### one\nThe handler attached to the size will executed at most once.\n\n```javascript\nBreakpoints.one('md', 'enter', function(){\n    console.info('this only appear once when enter md');\n});\n```\n\n### off\nRemove event handlers attached to size.\n\n```javascript\n// remove all events attached to sm size\nBreakpoints.off('sm');\n\n// remove all enter type events attached to md size\nBreakpoints.off('md', 'enter'); \n\n// remove specific event handler\nvar enterHandler = function(){};\nBreakpoints.on('lg', 'enter', enterHandler);\n\nBreakpoints.off('lg', {\n    enter: enterHandler\n})\n\n// alternative way\nBreakpoints.off('lg', 'enter', enterHandler);\n```\n\n### change\nAttach an event handler to the size change event\n\n```javascript\n// attach handler to change event\nBreakpoints.on('change', function(){\n    console.info('enter ' + this.current.name);\n});\n\n// altrnative example\nvar changeHandler = function(){\n    // do something \n};\nBreakpoints.on('change', changeHandler);\n\n// remove the handler\nBreakpoints.off('change', changeHandler);\n\n// remove all change handlers\nBreakpoints.off('change');\n```\n\n\n## Browser support\n\nTested on all major browsers.\n\n| \u003cimg src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/safari/safari_32x32.png\" alt=\"Safari\"\u003e | \u003cimg src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/chrome/chrome_32x32.png\" alt=\"Chrome\"\u003e | \u003cimg src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/firefox/firefox_32x32.png\" alt=\"Firefox\"\u003e | \u003cimg src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/edge/edge_32x32.png\" alt=\"Edge\"\u003e | \u003cimg src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/internet-explorer/internet-explorer_32x32.png\" alt=\"IE\"\u003e | \u003cimg src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/opera/opera_32x32.png\" alt=\"Opera\"\u003e |\n|:--:|:--:|:--:|:--:|:--:|:--:|\n| Latest ✓ | Latest ✓ | Latest ✓ | Latest ✓ | 9-11 ✓ | Latest ✓ |\n\n\n- [`matchMedia` browser support](http://caniuse.com/#search=matchMedia) work perfect on all modern browsers (IE10+, firefox, chrome, android and safari).\n- With some polyfills (like the ones included in [matchMedia.js](https://github.com/paulirish/matchMedia.js/)) Breakpoints works perfect in IE6-9 as well.\n\n\n## Contributing\nAnyone and everyone is welcome to contribute. Please take a moment to\nreview the [guidelines for contributing](CONTRIBUTING.md). Make sure you're using the latest version of `jquery-scrollTo` before submitting an issue. There are several ways to help out:\n\n* [Bug reports](CONTRIBUTING.md#bug-reports)\n* [Feature requests](CONTRIBUTING.md#feature-requests)\n* [Pull requests](CONTRIBUTING.md#pull-requests)\n* Write test cases for open bug issues\n* Contribute to the documentation\n\n## Development\n`jquery-scrollTo` is built modularly and uses Gulp as a build system to build its distributable files. To install the necessary dependencies for the build system, please run:\n\n```sh\nnpm install -g gulp\nnpm install -g babel-cli\nnpm install\n```\n\nThen you can generate new distributable files from the sources, using:\n```\ngulp build\n```\n\nMore gulp tasks can be found [here](CONTRIBUTING.md#available-tasks).\n\n## Changelog\nTo see the list of recent changes, see [Releases section](https://github.com/amazingSurge/jquery-scrollTo/releases).\n\n\n## Other Projects\n\nIf you like this project then I encourage you to check out a few of my other hand-selected projects.\n\n- [enquire.js](http://wicky.nillia.ms/enquire.js/) - A lightweight, pure JavaScript library for responding to CSS media queries.\n- [mediaquery](http://formstone.it/components/mediaquery/) - A jQuery plugin for responsive media query events.\n- [strapPoint](https://github.com/dannynimmo/strapPoint) - A small jQuery utility plugin to make working with Bootstrap breakpoints easier.\n- [pointbreak.js](https://github.com/weblinc/pointbreak.js) - It provides a friendly interface to matchMedia with named media queries and easy to create callbacks.\n\n## Copyright and license\n\nCopyright (C) 2016 amazingSurge.\n\nLicensed under [the LGPL license](LICENSE).\n\n[⬆ back to top](#table-of-contents)\n\n[bower-image]: https://img.shields.io/bower/v/breakpoints.js.svg?style=flat\n[bower-link]: https://david-dm.org/amazingSurge/breakpoints-js/dev-status.svg\n[npm-image]: https://badge.fury.io/js/breakpoints-js.svg?style=flat\n[npm-url]: https://npmjs.org/package/breakpoints-js\n[license]: https://img.shields.io/npm/l/breakpoints-js.svg?style=flat\n[prs-welcome]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg\n[daviddm-image]: https://david-dm.org/amazingSurge/breakpoints-js.svg?style=flat\n[daviddm-url]: https://david-dm.org/amazingSurge/breakpoints-js\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecreation%2Fbreakpoints-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthecreation%2Fbreakpoints-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecreation%2Fbreakpoints-js/lists"}