Skip to content
This repository was archived by the owner on Aug 1, 2020. It is now read-only.

Commit 40dc3de

Browse files
author
Fengyuan Chen
committed
Release v0.3.0
1 parent 0290a18 commit 40dc3de

12 files changed

+436
-201
lines changed

CHANGELOG.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
# Changelog
22

33

4+
## 0.3.0 (Dec 24, 2015)
5+
6+
- Add 2 new options: "view" and "viewed"
7+
- Add 2 new events: "view" and "viewed"
8+
- Add keyboard support: stop playing when tap the `Space` key
9+
- Fix lost transition after call full method in inline mode
10+
- Fix incorrect tooltip after switch image quickly
11+
12+
413
## 0.2.0 (Oct 18, 2015)
514

615
- Added one new method: "moveTo"
7-
- Improved the image loading and showing.
16+
- Improved the image loading and showing
817

918

1019
## 0.1.1 (Oct 7, 2015)
1120

12-
- Fixed the issue of modal closing after zoomed in and zoomed out.
21+
- Fixed the issue of modal closing after zoomed in and zoomed out
1322

1423

1524
## 0.1.0 (Sep 2, 2015)

README.md

+94-28
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
1-
# [Viewer](https://github.com/fengyuanchen/viewer)
1+
# Viewer
22

33
> A simple jQuery image viewing plugin.
44
5-
- [Demo](http://fengyuanchen.github.io/viewer)
5+
- [Homepage](http://fengyuanchen.github.io/viewer)
6+
- [Viewer without jQuery](https://github.com/fengyuanchen/viewerjs)
7+
8+
9+
10+
## Table of contents
11+
12+
- [Features](#features)
13+
- [Main](#main)
14+
- [Getting started](#getting-started)
15+
- [Keyboard support](#keyboard-support)
16+
- [Options](#options)
17+
- [Methods](#methods)
18+
- [Events](#events)
19+
- [No conflict](#no-conflict)
20+
- [Browser support](#browser-support)
21+
- [Contributing](#contributing)
22+
- [Versioning](#versioning)
23+
- [License](#license)
624

725

826

@@ -27,7 +45,7 @@
2745
dist/
2846
├── viewer.css ( 8 KB)
2947
├── viewer.min.css ( 7 KB)
30-
├── viewer.js (44 KB)
48+
├── viewer.js (45 KB)
3149
└── viewer.min.js (19 KB)
3250
```
3351

@@ -92,6 +110,7 @@ $('.images').viewer();
92110
> Only available in modal mode.
93111
94112
- `Esc`: Exit full screen or stop play.
113+
- `Space`: Stop play.
95114
- ``: View the previous image.
96115
- ``: View the next image.
97116
- ``: Zoom in the image.
@@ -100,6 +119,9 @@ $('.images').viewer();
100119
- `Ctrl + 1`: Zoom in to natural size.
101120

102121

122+
[⬆ back to top](#table-of-contents)
123+
124+
103125

104126
## Options
105127

@@ -322,25 +344,44 @@ A shortcut of the "hide.viewer" event.
322344
A shortcut of the "hidden.viewer" event.
323345

324346

347+
### view
348+
349+
- Type: `Function`
350+
- Default: `null`
351+
352+
A shortcut of the "view.viewer" event.
353+
354+
355+
### viewed
356+
357+
- Type: `Function`
358+
- Default: `null`
359+
360+
A shortcut of the "viewed.viewer" event.
361+
362+
363+
[⬆ back to top](#table-of-contents)
364+
365+
325366

326367
## Methods
327368

328-
As there is an **asynchronous** process when load the image(s), you **should call most of the methods after shown (modal mode) or built (inline mode)**, except "show" (modal mode) and "destroy".
369+
As there are some **asynchronous** processes when start the viewer, you should call a method only when it is available, see the following **lifecycle**:
329370

330371
```js
331-
// Modal mode
332372
$().viewer({
373+
built: function () {
374+
// 2 methods are available here: "show" and "destroy".
375+
},
333376
shown: function () {
334-
$().viewer('method', argument1, , argument2, ..., argumentN);
377+
// 9 methods are available here: "hide", "view", "prev", "next", "play", "stop", "full", "exit" and "destroy".
378+
},
379+
viewed: function () {
380+
// All methods are available here except "show".
381+
$(this).viewer('rotate', 90).viewer('scale', -1, -1);
335382
}
336383
}
337384

338-
// Inline mode
339-
$().viewer({
340-
built: function () {
341-
$().viewer('method', argument1, , argument2, ..., argumentN);
342-
}
343-
}
344385
```
345386
346387
@@ -468,7 +509,7 @@ $().viewer('zoomTo', 1); // Zoom to natural size (100%)
468509
469510
Rotate the image with a relative degree.
470511
471-
> Requires [CSS3 2D Transforms](http://caniuse.com/transforms2d) support (IE 9+).
512+
> Requires [CSS3 2D Transforms](https://developer.mozilla.org/en-US/docs/Web/CSS/transform) support ([IE 9+](http://caniuse.com/transforms2d)).
472513
473514
```js
474515
$().viewer('rotate', 90);
@@ -483,7 +524,7 @@ $().viewer('rotate', -90);
483524
484525
Rotate the image to an absolute degree.
485526
486-
> Requires [CSS3 2D Transforms](http://caniuse.com/transforms2d) support (IE 9+).
527+
> Requires [CSS3 2D Transforms](https://developer.mozilla.org/en-US/docs/Web/CSS/transform) support ([IE 9+](http://caniuse.com/transforms2d)).
487528
488529
```js
489530
$().viewer('rotateTo', 0); // Reset to zero degree
@@ -506,7 +547,7 @@ $().viewer('rotateTo', 360); // Rotate a full round
506547
507548
Scale the image.
508549
509-
> Requires [CSS3 2D Transforms](http://caniuse.com/transforms2d) support (IE 9+).
550+
> Requires [CSS3 2D Transforms](https://developer.mozilla.org/en-US/docs/Web/CSS/transform) support ([IE 9+](http://caniuse.com/transforms2d)).
510551
511552
```js
512553
$().viewer('scale', -1); // Flip both horizontal and vertical
@@ -524,7 +565,7 @@ $().viewer('scale', 1, -1); // Flip vertical
524565
525566
Scale the abscissa of the image.
526567
527-
> Requires [CSS3 2D Transforms](http://caniuse.com/transforms2d) support (IE 9+).
568+
> Requires [CSS3 2D Transforms](https://developer.mozilla.org/en-US/docs/Web/CSS/transform) support ([IE 9+](http://caniuse.com/transforms2d)).
528569
529570
```js
530571
$().viewer('scaleX', -1); // Flip horizontal
@@ -541,7 +582,7 @@ $().viewer('scaleX', -1); // Flip horizontal
541582
542583
Scale the ordinate of the image.
543584
544-
> Requires [CSS3 2D Transforms](http://caniuse.com/transforms2d) support (IE 9+).
585+
> Requires [CSS3 2D Transforms](https://developer.mozilla.org/en-US/docs/Web/CSS/transform) support ([IE 9+](http://caniuse.com/transforms2d)).
545586
546587
```js
547588
$().viewer('scaleY', -1); // Flip vertical
@@ -562,14 +603,14 @@ Stop play.
562603
563604
Enter modal mode.
564605
565-
> only available in inline mode.
606+
> Only available in inline mode.
566607
567608
568609
### exit()
569610
570611
Exit modal mode.
571612
572-
> only available in inline mode.
613+
> Only available in inline mode.
573614
574615
575616
### tooltip()
@@ -594,12 +635,15 @@ Reset the image to its initial state.
594635
Destroy the viewer and remove the instance.
595636
596637
638+
[⬆ back to top](#table-of-contents)
639+
640+
597641
598642
## Events
599643
600644
### build.viewer
601645
602-
This event fires when a viewer instance start to build.
646+
This event fires when a viewer instance starts to build.
603647
604648
605649
### built.viewer
@@ -609,30 +653,43 @@ This event fires when a viewer instance has built.
609653
610654
### show.viewer
611655
612-
This event fires when a viewer element start to show.
656+
This event fires when the viewer modal starts to show.
613657
614-
> only available in modal mode.
658+
> Only available in modal mode.
615659
616660
617661
### shown.viewer
618662
619-
This event fires when a viewer element has shown.
663+
This event fires when the viewer modal has shown.
620664
621-
> only available in modal mode.
665+
> Only available in modal mode.
622666
623667
624668
### hide.viewer
625669
626-
This event fires when a viewer element start to hide.
670+
This event fires when the viewer modal starts to hide.
627671
628-
> only available in modal mode.
672+
> Only available in modal mode.
629673
630674
631675
### hidden.viewer
632676
633-
This event fires when a viewer element has hidden.
677+
This event fires when the viewer modal has hidden.
678+
679+
> Only available in modal mode.
680+
681+
682+
### view.viewer
634683
635-
> only available in modal mode.
684+
This event fires when a viewer starts to show (view) an image.
685+
686+
687+
### viewed.viewer
688+
689+
This event fires when a viewer has shown (viewed) an image.
690+
691+
692+
[⬆ back to top](#table-of-contents)
636693
637694
638695
@@ -651,6 +708,12 @@ If you have to use other plugin with the same namespace, just call the `$.fn.vie
651708
652709
653710
711+
## Contributing
712+
713+
Please read through our [contributing guidelines](CONTRIBUTING.md).
714+
715+
716+
654717
## Browser support
655718
656719
- Chrome (latest 2)
@@ -672,3 +735,6 @@ Maintained under the [Semantic Versioning guidelines](http://semver.org/).
672735
## License
673736
674737
[MIT](http://opensource.org/licenses/MIT) © [Fengyuan Chen](http://chenfengyuan.com)
738+
739+
740+
[⬆ back to top](#table-of-contents)

demo/css/main.css

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/* Basic style
2-
* -------------------------------------------------------------------------- */
3-
41
/* Header */
52

63
.docs-header {

demo/js/main.js

+48-15
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,33 @@ $(function () {
66
var $images = $('.docs-pictures');
77
var $toggles = $('.docs-toggles');
88
var $buttons = $('.docs-buttons');
9-
var handler = function (e) {
10-
console.log(e.type);
11-
};
129
var options = {
1310
// inline: true,
1411
url: 'data-original',
15-
build: handler,
16-
built: handler,
17-
show: handler,
18-
shown: handler,
19-
hide: handler,
20-
hidden: handler
12+
build: function (e) {
13+
console.log(e.type);
14+
},
15+
built: function (e) {
16+
console.log(e.type);
17+
},
18+
show: function (e) {
19+
console.log(e.type);
20+
},
21+
shown: function (e) {
22+
console.log(e.type);
23+
},
24+
hide: function (e) {
25+
console.log(e.type);
26+
},
27+
hidden: function (e) {
28+
console.log(e.type);
29+
},
30+
view: function (e) {
31+
console.log(e.type);
32+
},
33+
viewed: function (e) {
34+
console.log(e.type);
35+
}
2136
};
2237

2338
function toggleButtons(mode) {
@@ -31,12 +46,30 @@ $(function () {
3146
}
3247

3348
$images.on({
34-
'build.viewer': handler,
35-
'built.viewer': handler,
36-
'show.viewer': handler,
37-
'shown.viewer': handler,
38-
'hide.viewer': handler,
39-
'hidden.viewer': handler
49+
'build.viewer': function (e) {
50+
console.log(e.type);
51+
},
52+
'built.viewer': function (e) {
53+
console.log(e.type);
54+
},
55+
'show.viewer': function (e) {
56+
console.log(e.type);
57+
},
58+
'shown.viewer': function (e) {
59+
console.log(e.type);
60+
},
61+
'hide.viewer': function (e) {
62+
console.log(e.type);
63+
},
64+
'hidden.viewer': function (e) {
65+
console.log(e.type);
66+
},
67+
'view.viewer': function (e) {
68+
console.log(e.type);
69+
},
70+
'viewed.viewer': function (e) {
71+
console.log(e.type);
72+
}
4073
}).viewer(options);
4174

4275
toggleButtons(options.inline ? 'inline' : 'modal');

0 commit comments

Comments
 (0)