Skip to content

Commit

Permalink
refactor: rename sequential data attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Allison Strandberg committed Jan 5, 2021
1 parent c21b121 commit 775ce24
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ If you want to increae the distance of the tooltip from the element, you can do
```

You can also run Chardin in sequenced mode, where one element will be displayed at a time, moving on to the next with a mouse click (or automatically after a set delay).
Add `data-chardinjs-sequenced="true"` entry to the body tag. Also add `data-chardinjs-auto="true"` and `data-chardinjs-delay="100"` for automatic movement through the elements. Delay is in milliseconds.
The default sequence is as loaded by the DOM, but this can be overridden using the tag `data-chardinjs-sequence` with a number.
Add `data-chardin-sequenced="true"` entry to the body tag. Also add `data-chardin-auto="true"` and `data-chardin-delay="100"` for automatic movement through the elements. Delay is in milliseconds.
The default sequence is as loaded by the DOM, but this can be overridden using the tag `data-chardin-sequence` with a number.
If no auto-traversal is set, clicking will move sequentially through the elements, clicking with the shift key down will move backwards through them.

```HTML
<body data-chardinjs-sequenced="true" data-chardinjs-auto="false" data-chardinjs-delay="800" >
<body data-chardin-sequenced="true" data-chardin-auto="false" data-chardin-delay="800" >
```

## Running
Expand Down
10 changes: 5 additions & 5 deletions chardinjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
this.data_attribute = 'data-chardin-intro';
this.chardinCssClasses = ["chardinjs-helper-layer", "chardinjs-show-element", "chardinjs-relative-position"];
this.$el = $(el);
this.sequenced = this.$el.data('chardinjs-sequenced') ? true : false;
this.sequenced = this.$el.data('chardin-sequenced') ? true : false;
this.sequencedItems = this._getSequencedElements();
this.sequenceIdx = 0;
this.active = false;
this.timeOut = null;
this.isAuto = this.$el.data('chardinjs-auto') ? true : false;
this.delayTime = this.$el.data('chardinjs-delay') || 2000;
this.isAuto = this.$el.data('chardin-auto') ? true : false;
this.delayTime = this.$el.data('chardin-delay') || 2000;

$(window).resize((function (_this) {
return function () {
Expand Down Expand Up @@ -459,8 +459,8 @@
chardinJs.prototype._getSequencedElements = function () {
return this.$el.find('*[' + this.data_attribute + ']:visible').sort(function (a, b) {
var left, right;
left = $(a).data('chardinjs-sequence') || 100;
right = $(b).data('chardinjs-sequence') || 100;
left = $(a).data('chardin-sequence') || 100;
right = $(b).data('chardin-sequence') || 100;
return left - right;
});
};
Expand Down
Loading

0 comments on commit 775ce24

Please sign in to comment.