Skip to content

Commit 184b83d

Browse files
author
Mark
committed
Use Prettier
1 parent 3198c21 commit 184b83d

13 files changed

+601
-105
lines changed

.huskyrc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
hooks: {
3+
'pre-commit': 'pretty-quick --staged',
4+
},
5+
};

.prettierignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
dist/
1+
dist/
2+
package*.json
3+
.gitignore
4+
.prettierignore

.prettierrc

Lines changed: 0 additions & 14 deletions
This file was deleted.

.prettierrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
singleQuote: true,
3+
tabWidth: 4,
4+
};

README.md

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,27 @@
44
# waitForElementTransition()
55

66
Let's say you have the problem (that many of us have) where you need to wait for the completion of your element's
7-
[CSS transition](https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Using_CSS_transitions)
8-
before your code continues. You can use this library and call a `waitForElementTransition` method to wait until
9-
the element finishes its css transition before doing other things in your javascript code.
7+
[CSS transition](https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Using_CSS_transitions)
8+
before your code continues. You can use this library and call a `waitForElementTransition` method to wait until
9+
the element finishes its css transition before doing other things in your javascript code.
1010

1111
## Benefits
1212

13-
* Easily wait for an element's css transition to end using JavaScript
14-
* Allows you to keep your transition/animation css properties separate from your JS
15-
* Native javascript with no dependencies
16-
* Safer and more reliable than `transitionstart` and `transitionend` events
17-
* Plays nicely with the latest specifications
13+
- Easily wait for an element's css transition to end using JavaScript
14+
- Allows you to keep your transition/animation css properties separate from your JS
15+
- Native javascript with no dependencies
16+
- Safer and more reliable than `transitionstart` and `transitionend` events
17+
- Plays nicely with the latest specifications
1818

1919
## Installation
2020

2121
You can either use the dist file directly in your project:
2222

2323
```html
24-
<script type="text/javascript" src="/dist/wait-for-element-transition.min.js"></script>
24+
<script
25+
type="text/javascript"
26+
src="/dist/wait-for-element-transition.min.js"
27+
></script>
2528
```
2629

2730
Or install via npm
@@ -36,58 +39,55 @@ and import
3639
import waitForElementTransition from 'wait-for-element-transition';
3740
```
3841

39-
4042
## Usage
4143

4244
Here's an example where we want to wait for an element's background color to change from black to red.
4345

4446
```html
4547
<style>
46-
47-
div {
48-
background-color: black;
49-
transition-property: background-color;
50-
transition-duration: 100ms;
51-
transition-timing-function: ease-out;
52-
}
53-
54-
.red {
55-
background-color: red;
56-
}
48+
div {
49+
background-color: black;
50+
transition-property: background-color;
51+
transition-duration: 100ms;
52+
transition-timing-function: ease-out;
53+
}
54+
55+
.red {
56+
background-color: red;
57+
}
5758
</style>
5859

5960
<div>Transition this element</div>
6061

61-
<script type="text/javascript" src="/dist/wait-for-element-transition.min.js"></script>
62+
<script
63+
type="text/javascript"
64+
src="/dist/wait-for-element-transition.min.js"
65+
></script>
6266
<script>
63-
const element = document.querySelector('div');
64-
element.classList.add('red'); // start transition
65-
waitForElementTransition(element).then(() => {
66-
// 100 milliseconds later...
67-
console.log('element background color changed to red!');
68-
});
67+
const element = document.querySelector('div');
68+
element.classList.add('red'); // start transition
69+
waitForElementTransition(element).then(() => {
70+
// 100 milliseconds later...
71+
console.log('element background color changed to red!');
72+
});
6973
</script>
70-
7174
```
7275

73-
If the element has already transitioned before the `waitForElementTransition()` is called, the `waitForElementTransition()`s
76+
If the element has already transitioned before the `waitForElementTransition()` is called, the `waitForElementTransition()`s
7477
promise will resolve immediately. So you can always guarantee that your code will run, just as it would synchronously.
7578

76-
7779
## Alternatives
7880

7981
### The `transitionend` event
8082

81-
Using the `transitionend` or `animationend` events on an Element will allow you to wait until an Element's transition
83+
Using the `transitionend` or `animationend` events on an Element will allow you to wait until an Element's transition
8284
has ended, but this approach is limited:
8385

8486
1. The events don't fire in the case where a transition is removed before completion (i.e. display is set to "none" or if
85-
the css property is removed) and
87+
the css property is removed) and
8688
1. The events don't fire when there are no css transition properties specified, which doesn't allow us to run the
87-
same animation-completion logic on elements which may or may not be animated.
89+
same animation-completion logic on elements which may or may not be animated.
8890

8991
### Web Animations
9092

91-
- Not supported in all browsers like Internet Explorer or Safari
92-
93-
93+
- Not supported in all browsers like Internet Explorer or Safari

karma.conf.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const tsconfig = require('./tsconfig.json');
22

3-
module.exports = function(config) {
3+
module.exports = function (config) {
44
config.set({
55
files: ['tests/**/*.ts', '*.ts'],
66

@@ -9,11 +9,11 @@ module.exports = function(config) {
99
},
1010
karmaTypescriptConfig: {
1111
compilerOptions: {
12-
module: "commonjs",
12+
module: 'commonjs',
1313
sourceMap: true,
14-
target: "es6"
14+
target: 'es6',
1515
},
16-
exclude: ["node_modules"]
16+
exclude: ['node_modules'],
1717
},
1818
reporters: ['progress'],
1919
frameworks: ['mocha', 'karma-typescript'],
@@ -23,6 +23,6 @@ module.exports = function(config) {
2323
browsers: ['ChromeHeadless'],
2424
autoWatch: true,
2525
singleRun: true,
26-
concurrency: Infinity
26+
concurrency: Infinity,
2727
});
2828
};

0 commit comments

Comments
 (0)