{"id":21033470,"url":"https://github.com/electerious/basicrotate","last_synced_at":"2025-05-15T13:32:10.600Z","repository":{"id":54222693,"uuid":"201616789","full_name":"electerious/basicRotate","owner":"electerious","description":"Rotate throw a set of 360 degree images using your mouse or finger.","archived":false,"fork":false,"pushed_at":"2022-10-01T13:59:20.000Z","size":1955,"stargazers_count":21,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T17:10:15.471Z","etag":null,"topics":[],"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/electerious.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"electerious","custom":["https://paypal.me/electerious","https://www.buymeacoffee.com/electerious"]}},"created_at":"2019-08-10T10:46:16.000Z","updated_at":"2025-03-10T16:25:42.000Z","dependencies_parsed_at":"2023-01-19T01:30:26.144Z","dependency_job_id":null,"html_url":"https://github.com/electerious/basicRotate","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electerious%2FbasicRotate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electerious%2FbasicRotate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electerious%2FbasicRotate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electerious%2FbasicRotate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/electerious","download_url":"https://codeload.github.com/electerious/basicRotate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254349467,"owners_count":22056353,"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-11-19T12:57:15.524Z","updated_at":"2025-05-15T13:32:08.390Z","avatar_url":"https://github.com/electerious.png","language":"JavaScript","funding_links":["https://github.com/sponsors/electerious","https://paypal.me/electerious","https://www.buymeacoffee.com/electerious","https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=CYKBESW577YWE"],"categories":[],"sub_categories":[],"readme":"# basicRotate\n\n[![Donate via PayPal](https://img.shields.io/badge/paypal-donate-009cde.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=CYKBESW577YWE)\n\nRotate throw a set of 360 degree images using your mouse or finger.\n\n## Contents\n\n- [Demos](#demos)\n- [Features](#features)\n- [Requirements](#requirements)\n- [Setup](#setup)\n- [Usage](#usage)\n- [API](#api)\n- [Instance API](#instance-api)\n- [Options](#options)\n\n## Demos\n\n| Name | Description | Link |\n|:-----------|:------------|:------------|\n| Default | Includes most features. | [Try it on CodePen](https://codepen.io/electerious/pen/wVYoYK) |\n\n## Features\n\n- Works in all modern browsers and IE11 ([with polyfills](#requirements))\n- Supports any kind of images\n- Zero dependencies\n- CommonJS and AMD support\n- Simple JS API\n\n## Requirements\n\nbasicRotate depends on the following browser APIs:\n\n- [Node​List​.prototype​.for​Each](https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach)\n- [Number.isFinite](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite)\n- [Object.assign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)\n\nSome of these APIs are capable of being polyfilled in older browsers. Check the linked resources above to determine if you must polyfill to achieve your desired level of browser support.\n\n## Setup\n\nWe recommend installing basicRotate using [npm](https://npmjs.com) or [yarn](https://yarnpkg.com).\n\n```sh\nnpm install basicrotate\n```\n\n```sh\nyarn add basicrotate\n```\n\nInclude the CSS file in the `head` tag and the JS file at the end of your `body` tag…\n\n```html\n\u003clink rel=\"stylesheet\" href=\"dist/basicRotate.min.css\"\u003e\n```\n\n```html\n\u003cscript src=\"dist/basicRotate.min.js\"\u003e\u003c/script\u003e\n```\n\n…or skip the JS file and use basicRotate as a module:\n\n```js\nconst basicRotate = require('basicrotate')\n```\n\n```js\nimport * as basicRotate from 'basicrotate'\n```\n\n## Usage\n\nCreate an element filled with equal-sized images. Add the `basicRotate` class and initialize basicRotate using the `basicRotate.create` function. That's it!\n\n```html\n\u003cdiv class=\"basicRotate\"\u003e\n\t\u003cimg src=\"1.jpg\"\u003e\n\t\u003cimg src=\"2.jpg\"\u003e\n\t\u003cimg src=\"3.jpg\"\u003e\n\t\u003c!-- ... --\u003e\n\u003c/div\u003e\n```\n\n```js\nbasicRotate.create(document.querySelector('.basicRotate'))\n```\n\n## API\n\n### .create(elem, opts)\n\nCreates a new basicRotate instance.\n\nBe sure to assign your instance to a variable. Using your instance, you can…\n\n* …get the current image index.\n* …jump back and forward.\n* …goto a specific image.\n\nExamples:\n\n```js\nconst instance = basicRotate.create(document.querySelector('#rotate'))\n```\n\n```js\nconst instance = basicRotate.create(document.querySelector('#rotate'), {\n\tindex: 1,\n\ttolerance: 5\n})\n```\n\n```js\nconst instance = basicRotate.create(document.querySelector('#rotate'), {\n\tbeforeChange: (instance, newIndex, oldIndex) =\u003e console.log('beforeChange', instance, newIndex, oldIndex),\n\tafterChange: (instance, newIndex, oldIndex) =\u003e console.log('afterChange', instance, newIndex, oldIndex)\n})\n```\n\nParameters:\n\n- `elem` `{Node}` The DOM element/node which contains all images.\n- `opts` `{?Object}` An object of [options](#options).\n\nReturns:\n\n- `{Object}` The created instance.\n\n## Instance API\n\nEach basicRotate instance has a handful of handy functions. Below are all of them along with a short description.\n\n### .current()\n\nReturns the current image index.\n\nExample:\n\n```js\nconst current = instance.current()\n```\n\nReturns:\n\n- `{Number}` Current image index.\n\n### .goto(newIndex)\n\nNavigates to an image by index and executes the beforeChange and afterChange callback functions.\n\nExample:\n\n```js\ninstance.goto(0)\n```\n\nParameters:\n\n- `newIndex` `{Number}` Index of the image to be displayed.\n\n### .prev()\n\nNavigates to the previous image and executes the beforeChange and afterChange callback functions.\n\nExample:\n\n```js\ninstance.prev()\n```\n\n### .next()\n\nNavigates to the next image and executes the beforeChange and afterChange callback functions.\n\nExample:\n\n```js\ninstance.next()\n```\n\n## Options\n\nThe option object can include the following properties:\n\n```js\n{\n\t/*\n\t * Initial image.\n\t */\n\tindex: 0,\n\t/*\n\t * Rotate image by dragging.\n\t */\n\tdraggable: true,\n\t/*\n\t * Dragging tolerance.\n\t * Small number (1) = Very sensitive = Fast.\n\t * Large number (∞) = Very insensitive = Slow.\n\t */\n\ttolerance: 10,\n\t/*\n\t * Dragging direction.\n\t * x (or basicRotate.DIRECTION_X) = Detect movements on the x-axis.\n\t * y (or basicRotate.DIRECTION_Y) = Detect movements on the y-axis.\n\t */\n\tindex: 'x',\n\t/*\n\t * Callback functions.\n\t * Returning false will stop the caller function and prevent the image from changing.\n\t */\n\tbeforeChange: (instance, newIndex, oldIndex) =\u003e {},\n\tafterChange: (instance, newIndex, oldIndex) =\u003e {}\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felecterious%2Fbasicrotate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felecterious%2Fbasicrotate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felecterious%2Fbasicrotate/lists"}