@splidejs/splide-extension-url-hash
Advanced tools
Comparing version 0.2.0 to 0.2.1
/*! | ||
* @splidejs/splide-extension-url-hash | ||
* Version : 0.2.0 | ||
* Version : 0.2.1 | ||
* License : MIT | ||
@@ -11,3 +11,3 @@ * Copyright: 2021 Naotoshi Fujita | ||
// ../splide/dist/js/splide.esm.js | ||
// node_modules/@splidejs/splide/dist/js/splide.esm.js | ||
function isArray(subject) { | ||
@@ -40,6 +40,6 @@ return Array.isArray(subject); | ||
} | ||
function unbind(targets, events) { | ||
function unbind(targets, events, callback) { | ||
forEachEvent(targets, events, (target, event2) => { | ||
listeners = listeners.filter((listener) => { | ||
if (listener[0] === target && listener[1] === event2) { | ||
if (listener[0] === target && listener[1] === event2 && (!callback || listener[2] === callback)) { | ||
target.removeEventListener(event2, listener[2], listener[3]); | ||
@@ -74,3 +74,3 @@ return false; | ||
// ../splide/src/js/utils/dom/getAttribute/getAttribute.ts | ||
// node_modules/@splidejs/splide/src/js/utils/dom/getAttribute/getAttribute.ts | ||
function getAttribute2(elm, attr) { | ||
@@ -132,3 +132,3 @@ return elm.getAttribute(attr); | ||
* Splide.js | ||
* Version : 3.0.0 | ||
* Version : 3.6.1 | ||
* License : MIT | ||
@@ -135,0 +135,0 @@ * Copyright: 2021 Naotoshi Fujita |
/*! | ||
* @splidejs/splide-extension-url-hash | ||
* Version : 0.2.0 | ||
* Version : 0.2.1 | ||
* License : MIT | ||
* Copyright: 2021 Naotoshi Fujita | ||
*/ | ||
// ../splide/dist/js/splide.esm.js | ||
// node_modules/@splidejs/splide/dist/js/splide.esm.js | ||
function isArray(subject) { | ||
@@ -35,6 +35,6 @@ return Array.isArray(subject); | ||
} | ||
function unbind(targets, events) { | ||
function unbind(targets, events, callback) { | ||
forEachEvent(targets, events, (target, event2) => { | ||
listeners = listeners.filter((listener) => { | ||
if (listener[0] === target && listener[1] === event2) { | ||
if (listener[0] === target && listener[1] === event2 && (!callback || listener[2] === callback)) { | ||
target.removeEventListener(event2, listener[2], listener[3]); | ||
@@ -69,3 +69,3 @@ return false; | ||
// ../splide/src/js/utils/dom/getAttribute/getAttribute.ts | ||
// node_modules/@splidejs/splide/src/js/utils/dom/getAttribute/getAttribute.ts | ||
function getAttribute2(elm, attr) { | ||
@@ -127,3 +127,3 @@ return elm.getAttribute(attr); | ||
* Splide.js | ||
* Version : 3.0.0 | ||
* Version : 3.6.1 | ||
* License : MIT | ||
@@ -130,0 +130,0 @@ * Copyright: 2021 Naotoshi Fujita |
/*! | ||
* @splidejs/splide-extension-url-hash | ||
* Version : 0.2.0 | ||
* Version : 0.2.1 | ||
* License : MIT | ||
@@ -47,6 +47,6 @@ * Copyright: 2021 Naotoshi Fujita | ||
function unbind(targets, events) { | ||
function unbind(targets, events, callback) { | ||
forEachEvent(targets, events, function (target, event2) { | ||
listeners = listeners.filter(function (listener) { | ||
if (listener[0] === target && listener[1] === event2) { | ||
if (listener[0] === target && listener[1] === event2 && (!callback || listener[2] === callback)) { | ||
target.removeEventListener(event2, listener[2], listener[3]); | ||
@@ -163,3 +163,3 @@ return false; | ||
* Splide.js | ||
* Version : 3.0.0 | ||
* Version : 3.6.1 | ||
* License : MIT | ||
@@ -166,0 +166,0 @@ * Copyright: 2021 Naotoshi Fujita |
/*! | ||
* @splidejs/splide-extension-url-hash | ||
* Version : 0.2.0 | ||
* Version : 0.2.1 | ||
* License : MIT | ||
* Copyright: 2021 Naotoshi Fujita | ||
*/(function(a){typeof define=="function"&&define.amd?define(a):a()})(function(){"use strict";function a(e){return Array.isArray(e)}function b(e){return a(e)?e:[e]}function x(e,i){b(e).forEach(i)}var T="active",m="destroy";function I(e){var i=e.event,c={},u=[];function w(t,f,o){i.on(t,f,c,o)}function p(t){i.off(t,c)}function d(t,f,o,r){h(t,f,function(n,s){u.push([n,s,o,r]),n.addEventListener(s,o,r)})}function l(t,f){h(t,f,function(o,r){u=u.filter(function(n){return n[0]===o&&n[1]===r?(o.removeEventListener(r,n[2],n[3]),!1):!0})})}function h(t,f,o){x(t,function(r){r&&f.split(" ").forEach(o.bind(null,r))})}function E(){u=u.filter(function(t){return l(t[0],t[1])}),i.offBy(c)}return i.on(m,E,c),{on:w,off:p,emit:i.emit,bind:d,unbind:l,destroy:E}}function y(e,i){return e.getAttribute(i)}var A="data-splide-hash";function H(e,i,c){var u=I(e),w=u.on,p=u.bind,d=i.Controller,l=d.setIndex,h=d.go;function E(){var n=r(location.hash);l(n>-1?n:c.start||0)}function t(){w(T,f),p(window,"hashchange",o)}function f(n){var s=y(n.slide,A);s?location.hash=s:history?history.replaceState(null,null," "):location.hash=""}function o(){var n=r(location.hash);n>-1&&h(n)}function r(n){if(n=n.replace("#",""),n){for(var s=i.Elements.slides,v=0;v<s.length;v++)if(y(s[v],A)===n)return v}return-1}return{setup:E,mount:t}}typeof window!="undefined"&&(window.splide=window.splide||{},window.splide.Extensions=window.splide.Extensions||{},window.splide.Extensions.URLHash=H);/*! | ||
*/(function(d){typeof define=="function"&&define.amd?define(d):d()})(function(){"use strict";function d(i){return Array.isArray(i)}function x(i){return d(i)?i:[i]}function T(i,o){x(i).forEach(o)}var b="active",m="destroy";function I(i){var o=i.event,c={},s=[];function w(t,u,r){o.on(t,u,c,r)}function p(t){o.off(t,c)}function a(t,u,r,f){l(t,u,function(n,e){s.push([n,e,r,f]),n.addEventListener(e,r,f)})}function h(t,u,r){l(t,u,function(f,n){s=s.filter(function(e){return e[0]===f&&e[1]===n&&(!r||e[2]===r)?(f.removeEventListener(n,e[2],e[3]),!1):!0})})}function l(t,u,r){T(t,function(f){f&&u.split(" ").forEach(r.bind(null,f))})}function E(){s=s.filter(function(t){return h(t[0],t[1])}),o.offBy(c)}return o.on(m,E,c),{on:w,off:p,emit:o.emit,bind:a,unbind:h,destroy:E}}function y(i,o){return i.getAttribute(o)}var A="data-splide-hash";function H(i,o,c){var s=I(i),w=s.on,p=s.bind,a=o.Controller,h=a.setIndex,l=a.go;function E(){var n=f(location.hash);h(n>-1?n:c.start||0)}function t(){w(b,u),p(window,"hashchange",r)}function u(n){var e=y(n.slide,A);e?location.hash=e:history?history.replaceState(null,null," "):location.hash=""}function r(){var n=f(location.hash);n>-1&&l(n)}function f(n){if(n=n.replace("#",""),n){for(var e=o.Elements.slides,v=0;v<e.length;v++)if(y(e[v],A)===n)return v}return-1}return{setup:E,mount:t}}typeof window!="undefined"&&(window.splide=window.splide||{},window.splide.Extensions=window.splide.Extensions||{},window.splide.Extensions.URLHash=H);/*! | ||
* Splide.js | ||
* Version : 3.0.0 | ||
* Version : 3.6.1 | ||
* License : MIT | ||
* Copyright: 2021 Naotoshi Fujita | ||
*/}); |
{ | ||
"name": "@splidejs/splide-extension-url-hash", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "The extension of Splide for URL hash navigation.", | ||
@@ -28,21 +28,21 @@ "author": "Naotoshi Fujita", | ||
"devDependencies": { | ||
"@babel/core": "^7.15.5", | ||
"@babel/preset-env": "^7.15.4", | ||
"@babel/core": "^7.16.0", | ||
"@babel/preset-env": "^7.16.4", | ||
"@rollup/plugin-babel": "^5.3.0", | ||
"@rollup/plugin-node-resolve": "^13.0.4", | ||
"@splidejs/splide": "^3.0.0", | ||
"@types/jest": "^27.0.1", | ||
"@typescript-eslint/eslint-plugin": "^4.30.0", | ||
"@typescript-eslint/parser": "^4.30.0", | ||
"babel-jest": "^27.1.0", | ||
"babel-loader": "^8.2.2", | ||
"@rollup/plugin-node-resolve": "^13.0.6", | ||
"@splidejs/splide": "^3.6.1", | ||
"@types/jest": "^27.0.3", | ||
"@typescript-eslint/eslint-plugin": "^5.4.0", | ||
"@typescript-eslint/parser": "^5.4.0", | ||
"babel-jest": "^27.3.1", | ||
"babel-loader": "^8.2.3", | ||
"chokidar": "^3.5.2", | ||
"esbuild": "^0.12.26", | ||
"eslint": "^7.32.0", | ||
"jest": "^27.1.0", | ||
"rollup": "^2.56.3", | ||
"rollup-plugin-esbuild": "^4.5.0", | ||
"ts-jest": "^27.0.5", | ||
"esbuild": "^0.13.15", | ||
"eslint": "^8.3.0", | ||
"jest": "^27.3.1", | ||
"rollup": "^2.60.1", | ||
"rollup-plugin-esbuild": "^4.7.2", | ||
"ts-jest": "^27.0.7", | ||
"tslib": "^2.3.1", | ||
"typescript": "^4.4.2" | ||
"typescript": "^4.5.2" | ||
}, | ||
@@ -49,0 +49,0 @@ "scripts": { |
@@ -1,53 +0,33 @@ | ||
# URL Hash Navigation - Splide Extension | ||
This is an extension of the [Splide](https://github.com/Splidejs/splide) slider library for listening to hash change and move a slide to a slide having the hash name. | ||
<div align="center"> | ||
<a href="https://splidejs.com"> | ||
<img alt="Splide" src="./images/logo.svg" width="70"> | ||
</a> | ||
Also, an initial slide will correspond with the URL hash. | ||
<h1>URL Hash - Splide Extension</h1> | ||
* [Demo and Document](https://splidejs.com/url-hash-navigation/) | ||
<p> | ||
The extension for syncing a <a href="https://github.com/Splidejs/splide">Splide</a> slider with URL hash. | ||
</p> | ||
## Installation | ||
### NPM(Recommended) | ||
1. Get the latest extension by NPM: | ||
```bash | ||
$ npm install @splidejs/splide-extension-url-hash | ||
``` | ||
1. Mount the extension to the Splide. | ||
```javascript | ||
import Splide from '@splidejs/splide'; | ||
import URLHash from '@splidejs/splide-extension-url-hash'; | ||
new Splide( '#splide' ).mount( { URLHash } ); | ||
``` | ||
### CDN or Hosting Files | ||
1. Visit [jsDelivr](https://www.jsdelivr.com/package/npm/@splidejs/splide-extension-url-hash) and get the links of the latest files or download files from the dist library. | ||
1. Import minified stylesheet and JavaScript files on your site: | ||
```html | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@splidejs/splide-extension-url-hash@0.0.2/dist/css/splide-extension-url-hash.min.css"> | ||
<script src="https://cdn.jsdelivr.net/npm/@splidejs/splide-extension-url-hash@0.0.2/dist/js/splide-extension-url-hash.min.js"> | ||
``` | ||
Note that version numbers above are incorrect. | ||
1. Mount the extension to the Splide. | ||
```javascript | ||
new Splide( '#splide' ).mount( window.splide.Extensions ); | ||
``` | ||
[![](https://data.jsdelivr.com/v1/package/npm/@splidejs/splide-extension-url-hash/badge)](https://www.jsdelivr.com/package/npm/@splidejs/splide-extension-url-hash) | ||
### HTML | ||
Set hash values to slides by "data-splide-hash" data attribute: | ||
```html | ||
<div class="splide"> | ||
<div class="splide__track"> | ||
<ul class="splide__list"> | ||
<li class="splide__slide" data-splide-hash="slide01"> | ||
</li> | ||
<li class="splide__slide" data-splide-hash="slide02"> | ||
</li> | ||
<li class="splide__slide" data-splide-hash="slide03"> | ||
</li> | ||
</ul> | ||
</div> | ||
<p> | ||
<a href="https://splidejs.com/extensions/url-hash/#overview">Demo</a> | ||
<br> | ||
<a href="https://splidejs.com/extensions/url-hash/">Getting Started</a> | ||
<br> | ||
<a href="https://splidejs.com/">Splide</a> | ||
</p> | ||
</div> | ||
## Packages | ||
The package is available on NPM and [jsDelivr](https://www.jsdelivr.com/package/npm/@splidejs/splide-extension-url-hash). | ||
``` | ||
$ npm install @splidejs/splide-extension-url-hash | ||
``` | ||
## License | ||
Splide is released under the MIT license. | ||
© 2020 Naotoshi Fujita | ||
Splide is released under the MIT license. | ||
© 2021 Naotoshi Fujita |
const rollup = require( 'rollup' ).rollup; | ||
const resolve = require( '@rollup/plugin-node-resolve' ).nodeResolve; | ||
const esbuild = require( 'rollup-plugin-esbuild' ); | ||
const esbuild = require( 'rollup-plugin-esbuild' ).default; | ||
const banner = require( './constants/banner' ); | ||
@@ -5,0 +5,0 @@ const name = 'splide-extension-url-hash'; |
const rollup = require( 'rollup' ).rollup; | ||
const esbuild = require( 'rollup-plugin-esbuild' ); | ||
const esbuild = require( 'rollup-plugin-esbuild' ).default; | ||
const babel = require( '@rollup/plugin-babel' ); | ||
@@ -4,0 +4,0 @@ const resolve = require( '@rollup/plugin-node-resolve' ).nodeResolve; |
import { Splide } from '@splidejs/splide'; | ||
import { fire } from '@splidejs/splide/src/js/test'; | ||
import { buildHtml } from '../../../test/fixtures'; | ||
@@ -56,1 +55,7 @@ import { URLHash } from '../URLHash'; | ||
} ); | ||
function fire( target: Window | Document | Element, type: string ): Event { | ||
const e = new Event( type ); | ||
target.dispatchEvent( e ); | ||
return e; | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
164124
158
1186
0
34