Skip to content

Commit 311c63a

Browse files
Add Transition Effect Example
1 parent a883af6 commit 311c63a

File tree

4 files changed

+49
-2
lines changed

4 files changed

+49
-2
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ This project exists thanks to all the people who contribute.
4646
Release Notes
4747
-------------
4848

49+
### 2.1.3
50+
51+
- Added transition effect example.
52+
- Removed opacity value rounding internally.
53+
- Updated to pass the Firefox extension validator (#57)
54+
4955
### 2.1.2
5056

5157
- Updated the donation target.

color-picker.transition.html

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!DOCTYPE html>
2+
<html dir="ltr">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta content="width=device-width" name="viewport">
6+
<title>Color Picker</title>
7+
<link href="color-picker.min.css" rel="stylesheet">
8+
</head>
9+
<body>
10+
<p><input type="text"></p>
11+
<script src="color-picker.min.js"></script>
12+
<script>
13+
14+
var picker = new CP(document.querySelector('input'));
15+
16+
picker.on('change', function(r, g, b, a) {
17+
this.source.value = this.color(r, g, b, a);
18+
});
19+
20+
picker.self.style.opacity = 0;
21+
picker.self.style.transition = 'opacity .5s ease';
22+
23+
picker.self.addEventListener('transitionend', function() {
24+
var opacity = +(this.style.opacity || 0);
25+
0 === opacity && picker.exit(); // Hide color picker pane on transition end
26+
});
27+
28+
picker.on('focus', function() {
29+
this.enter();
30+
this.self.style.opacity = 1;
31+
});
32+
33+
picker.on('blur', function() {
34+
// this.exit();
35+
this.self.style.opacity = 0;
36+
});
37+
38+
</script>
39+
</body>
40+
</html>

index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
<body>
6767
<p>Do you like this project? Please support my <a href="https://github.com/mecha-cms">Mecha CMS</a> project too. Thank you!</p>
6868
<header>
69-
<h1>Color Picker v2.1.2</h1>
69+
<h1>Color Picker v2.1.3</h1>
7070
<p>Color Picker is a simple JavaScript application that aims to provide custom color picker feature to the web with the most basic appearance and usability.</p>
7171
<hr>
7272
</header>
@@ -141,6 +141,7 @@ <h2>Examples</h2>
141141
<li><a href="color-picker.events.html" target="_blank">Show and Hide Color Picker with Double Click</a></li>
142142
<li><a href="color-picker.close.html" target="_blank">Add Close Button to the Color Picker</a></li>
143143
<li><a href="color-picker.static.html" target="_blank">Static Color Picker</a></li>
144+
<li><a href="color-picker.transition.html" target="_blank">Transition Effects</a></li>
144145
<li><a href="color-picker.replace.html" target="_blank">Replace Text Input with Hidden Input</a></li>
145146
<li><a href="color-picker.pop.html" target="_blank">Destroy Color Picker</a></li>
146147
<li><a href="color-picker.fit.html" target="_blank">Auto-Positioned to the Reachable Area in the Document</a></li>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@taufik-nurrohman/color-picker",
33
"description": "A simple color picker application written in pure JavaScript, for modern browsers.",
4-
"version": "2.1.2",
4+
"version": "2.1.3",
55
"main": "color-picker.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1",

0 commit comments

Comments
 (0)