Skip to content

Commit 8f5cfb9

Browse files
Merge pull request #207 from technote-space/release/next-v1.4.30
release: v1.5.0
2 parents 16bb8bb + db3b63a commit 8f5cfb9

File tree

9 files changed

+2193
-1557
lines changed

9 files changed

+2193
-1557
lines changed

README.ja.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
- [font_weight](#font_weight)
3636
- [repeat](#repeat)
3737
- [stripe](#stripe)
38+
- [rtl](#rtl)
3839
- [個別に値を指定する方法](#%E5%80%8B%E5%88%A5%E3%81%AB%E5%80%A4%E3%82%92%E6%8C%87%E5%AE%9A%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95)
3940
- [例1: 色の変更](#%E4%BE%8B1-%E8%89%B2%E3%81%AE%E5%A4%89%E6%9B%B4)
4041
- [例2: 複数設定](#%E4%BE%8B2-%E8%A4%87%E6%95%B0%E8%A8%AD%E5%AE%9A)
@@ -85,27 +86,31 @@ $('.marker-animation').markerAnimation({
8586
color: '#fe9'
8687
});
8788
```
89+
8890
### thickness
8991
マーカーの太さを指定
9092
```javascript
9193
$('.marker-animation').markerAnimation({
9294
thickness: '.6em'
9395
});
9496
```
97+
9598
### duration
9699
マーカーを塗るのを完了するまでの時間を指定
97100
```javascript
98101
$('.marker-animation').markerAnimation({
99102
duration: '2s'
100103
});
101104
```
105+
102106
### delay
103107
マーカーを塗るのを開始するまでの時間を指定
104108
```javascript
105109
$('.marker-animation').markerAnimation({
106110
duration: '.1s'
107111
});
108112
```
113+
109114
### font_weight
110115
文字の太さを指定
111116
```javascript
@@ -115,6 +120,7 @@ $('.marker-animation').markerAnimation({
115120
```
116121
デフォルトは太字です。
117122
太字にしない場合はnullを設定してください。
123+
118124
### repeat
119125
アニメーションを繰り返すかどうかを指定
120126
```javascript
@@ -123,6 +129,7 @@ $('.marker-animation').markerAnimation({
123129
});
124130
```
125131
trueにすると一度画面から外れて再び表示された際に再度アニメーションが実行されます。
132+
126133
### stripe
127134
ストライプデザインにするかどうかを指定
128135
```javascript
@@ -133,6 +140,14 @@ $('.marker-animation').markerAnimation({
133140
これが `true` の場合はアニメーションなしの動作になります。
134141
![stripe](https://raw.githubusercontent.com/technote-space/jquery.marker-animation/images/stripe.png)
135142

143+
### rtl
144+
右書き動作にするかどうかを指定
145+
```javascript
146+
$('.marker-animation').markerAnimation({
147+
rtl: false
148+
});
149+
```
150+
136151
## 個別に値を指定する方法
137152
`data-ma_[オプション名]` の形式で個別にオプションを指定することが可能です。
138153
### 例1: 色の変更

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jQuery plugin to add under line animation like highlighter.
3535
- [font_weight](#font_weight)
3636
- [repeat](#repeat)
3737
- [stripe](#stripe)
38+
- [rtl](#rtl)
3839
- [How to set the value for each](#how-to-set-the-value-for-each)
3940
- [e.g. Change color](#eg-change-color)
4041
- [e.g Multiple options](#eg-multiple-options)
@@ -82,27 +83,31 @@ $('.marker-animation').markerAnimation({
8283
color: '#fe9'
8384
});
8485
```
86+
8587
### thickness
8688
Set the thickness of line
8789
```javascript
8890
$('.marker-animation').markerAnimation({
8991
thickness: '.6em'
9092
});
9193
```
94+
9295
### duration
9396
Set the time to complete drawing a line
9497
```javascript
9598
$('.marker-animation').markerAnimation({
9699
duration: '2s'
97100
});
98101
```
102+
99103
### delay
100104
Set the time to start drawing a line
101105
```javascript
102106
$('.marker-animation').markerAnimation({
103107
duration: '.1s'
104108
});
105109
```
110+
106111
### font_weight
107112
Set the thickness of characters
108113
```javascript
@@ -112,6 +117,7 @@ $('.marker-animation').markerAnimation({
112117
```
113118
\[default = `bold`]
114119
If you do not want to make it bold, please set `null`.
120+
115121
### repeat
116122
Set whether to repeat the animation
117123
```javascript
@@ -120,6 +126,7 @@ $('.marker-animation').markerAnimation({
120126
});
121127
```
122128
If this set to true, the animation will be executed again when it is off screen and displayed again.
129+
123130
### stripe
124131
Set whether to make it stripe design
125132
```javascript
@@ -131,6 +138,14 @@ If this set to true, the animation will not be executed.
131138

132139
![stripe](https://raw.githubusercontent.com/technote-space/jquery.marker-animation/images/stripe.png)
133140

141+
### rtl
142+
Set whether to support rtl
143+
```javascript
144+
$('.marker-animation').markerAnimation({
145+
rtl: false
146+
});
147+
```
148+
134149
## How to set the value for each
135150
You can set options in the following format.
136151
```

__tests__/functions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,10 @@ describe('getCss', () => {
162162
duration: ZERO_SEC,
163163
'padding_bottom': 'a',
164164
cssFilter: css => css,
165+
rtl: true,
165166
});
166167
expect(css).toHaveProperty('background-position');
167-
expect(css['background-position']).toBe('left -100% center');
168+
expect(css['background-position']).toBe('right 0 center');
168169
});
169170

170171
it('should get stripe css', () => {

bin/gh-pages/plugin.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,17 @@ $(() => {
7575
<p>
7676
Dolly'll never go away again
7777
</p>
78-
78+
<p style="direction: rtl">
79+
<bdo lang="ar" dir="rtl">
80+
<span class="marker-animation" data-ma_rtl="true" data-ma_repeat="true">
81+
هذا اختبار اللغة العربية.
82+
</span>
83+
هل هذه المكتبة تعمل بشكل صحيح؟
84+
<span class="marker-animation" data-ma_rtl="true" data-ma_color="#00ffcc">
85+
إذا كان لديك أي مشاكل ، يرجى الإبلاغ عنها.
86+
</span>
87+
</bdo>
88+
</p>
7989
<p>
8090
<a class="btn btn-light-blue reset-animation">Reset</a>
8191
</p>

package.json

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,62 @@
11
{
22
"name": "jquery.marker-animation",
3-
"version": "1.4.30",
3+
"version": "1.5.0",
44
"description": "Marker animation jQuery plugin",
5-
"author": {
6-
"name": "Technote",
7-
"email": "technote.space@gmail.com",
8-
"url": "https://technote.space"
9-
},
10-
"license": "MIT",
115
"keywords": [
126
"jquery-plugin",
137
"marker animation",
148
"highlighter"
159
],
1610
"homepage": "https://github.com/technote-space/jquery.marker-animation#readme",
11+
"bugs": {
12+
"url": "https://github.com/technote-space/jquery.marker-animation/issues"
13+
},
1714
"repository": {
1815
"type": "git",
1916
"url": "https://github.com/technote-space/jquery.marker-animation.git"
2017
},
21-
"bugs": {
22-
"url": "https://github.com/technote-space/jquery.marker-animation/issues"
18+
"license": "MIT",
19+
"author": {
20+
"name": "Technote",
21+
"email": "technote.space@gmail.com",
22+
"url": "https://technote.space"
2323
},
2424
"main": "build/index.js",
2525
"files": [
2626
"build"
2727
],
28+
"scripts": {
29+
"build": "webpack --mode production --config webpack.config.js",
30+
"cover": "jest --coverage",
31+
"cover:update": "jest --coverage --updateSnapshot",
32+
"develop": "webpack --mode development --config webpack.config.js",
33+
"lint": "eslint 'src/**/*.js' '__tests__/**/*.js' --cache",
34+
"lint:fix": "eslint --fix 'src/**/*.js' '__tests__/**/*.js'",
35+
"start": "yarn build",
36+
"test": "yarn lint && yarn cover",
37+
"test:update": "yarn lint && yarn cover:update",
38+
"update": "npx npm-check-updates -u && yarn install && yarn upgrade && yarn audit"
39+
},
2840
"devDependencies": {
2941
"@babel/core": "^7.11.6",
3042
"@babel/plugin-proposal-object-rest-spread": "^7.11.0",
3143
"@babel/plugin-transform-react-jsx": "^7.10.4",
3244
"@babel/plugin-transform-runtime": "^7.11.5",
3345
"@babel/preset-env": "^7.11.5",
3446
"@babel/register": "^7.11.5",
35-
"babel-jest": "^26.3.0",
47+
"babel-jest": "^26.5.2",
3648
"babel-loader": "^8.1.0",
3749
"duplicate-package-checker-webpack-plugin": "^3.0.0",
3850
"enzyme": "^3.11.0",
39-
"enzyme-to-json": "^3.5.0",
40-
"eslint": "^7.9.0",
41-
"jest": "^26.4.2",
51+
"enzyme-to-json": "^3.6.1",
52+
"eslint": "^7.11.0",
53+
"jest": "^26.5.3",
4254
"jquery-inview": "^1.1.2",
4355
"speed-measure-webpack-plugin": "^1.3.3",
44-
"webpack": "^4.44.2",
45-
"webpack-cli": "^3.3.12"
56+
"webpack": "^5.0.0",
57+
"webpack-cli": "^4.0.0"
4658
},
4759
"publishConfig": {
4860
"access": "public"
49-
},
50-
"scripts": {
51-
"build": "webpack --mode production --config webpack.config.js",
52-
"start": "yarn build",
53-
"test": "yarn lint && yarn cover",
54-
"test:update": "yarn lint && yarn cover:update",
55-
"lint": "eslint 'src/**/*.js' '__tests__/**/*.js' --cache",
56-
"lint:fix": "eslint --fix 'src/**/*.js' '__tests__/**/*.js'",
57-
"cover": "jest --coverage",
58-
"cover:update": "jest --coverage --updateSnapshot",
59-
"develop": "webpack --mode development --config webpack.config.js",
60-
"update": "npx npm-check-updates -u && yarn install && yarn upgrade && yarn audit"
6161
}
6262
}

src/constants.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
export const NAMESPACE = 'markerAnimation';
2-
export const PREFIX = 'ma_';
3-
export const RESET_KEYS = [
1+
export const NAMESPACE = 'markerAnimation';
2+
export const PREFIX = 'ma_';
3+
export const RESET_KEYS = [
44
'background',
55
'padding-bottom',
66
'font-weight',
77
'transition',
88
];
9-
export const MARKER_DATA = 'data-marker_animation';
10-
export const ZERO_SEC = '0s';
9+
export const MARKER_DATA = 'data-marker_animation';
10+
export const ZERO_SEC = '0s';
1111
export const DESTROY_EVENT = `destroy.${NAMESPACE}`;
1212
export const REFRESH_EVENT = `refresh.${NAMESPACE}`;
13-
export const INVIEW_EVENT = `inview.${NAMESPACE}`;
13+
export const INVIEW_EVENT = `inview.${NAMESPACE}`;

src/defaults.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ export const SETTINGS_DEFAULTS = {
1212
cssFilter: function(css) {
1313
return css;
1414
},
15+
rtl: false,
1516
};

src/functions.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,31 @@ export const isStatic = options => options.stripe || (ZERO_SEC === options.delay
6161
*/
6262
export const getCss = options => options.cssFilter(options.stripe ? getStripeCss(options) : getMarkerCss(options));
6363

64+
/**
65+
* @param {object} options options
66+
* @returns {string} direction
67+
*/
68+
const getDirection = options => options.rtl ? 'right' : 'left';
69+
70+
/**
71+
* @param {object} options options
72+
* @returns {string} percentage
73+
*/
74+
const getStartPercentage = options => options.rtl ? '0' : '-100%';
75+
76+
/**
77+
* @param {object} options options
78+
* @returns {string} percentage
79+
*/
80+
const getGoalPercentage = options => options.rtl ? '100%' : '0';
81+
6482
/**
6583
* @param {object} options options
6684
* @returns {object} css
6785
*/
6886
const getCommonCss = options => Object.assign({
6987
'display': 'inline',
70-
'background-position': 'left 0 center',
88+
'background-position': `${getDirection(options)} ${getGoalPercentage(options)} center`,
7189
'padding-bottom': options.padding_bottom,
7290
}, options.font_weight ? {
7391
'font-weight': options.font_weight,
@@ -82,7 +100,7 @@ const getMarkerCss = options => Object.assign({}, getCommonCss(options), {
82100
'background-repeat': 'repeat-x',
83101
'background-image': `linear-gradient(to right, rgba(255,255,255,0) 50%, ${options.color} 50%)`,
84102
}, isStatic(options) ? {
85-
'background-position': 'left -100% center',
103+
'background-position': `${getDirection(options)} ${getStartPercentage(options)} center`,
86104
} : {});
87105

88106
/**
@@ -133,7 +151,7 @@ export const stop = target => {
133151
export const onInView = (target, options) => {
134152
target.stop(true, true).css({
135153
transition: `background-position ${options.duration} ${options.function} ${options.delay}`,
136-
'background-position': 'left -100% center',
154+
'background-position': `${getDirection(options)} ${getStartPercentage(options)} center`,
137155
});
138156
if (!options.repeat) {
139157
stop(target);

0 commit comments

Comments
 (0)