Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Web-Comic-Reader
Commits
47a2c4b4
Commit
47a2c4b4
authored
Apr 21, 2017
by
afzafri
Browse files
lightGallery Zoom plugin
parent
f3aac110
Changes
1
Hide whitespace changes
Inline
Side-by-side
assets/js/lg-zoom.min.js
0 → 100644
View file @
47a2c4b4
/*! lg-zoom - v1.0.4 - 2016-12-20
* http://sachinchoolur.github.io/lightGallery
* Copyright (c) 2016 Sachin N; Licensed GPLv3 */
!
function
(
a
,
b
){
"
function
"
==
typeof
define
&&
define
.
amd
?
define
([
"
jquery
"
],
function
(
a
){
return
b
(
a
)}):
"
object
"
==
typeof
exports
?
module
.
exports
=
b
(
require
(
"
jquery
"
)):
b
(
jQuery
)}(
this
,
function
(
a
){
!
function
(){
"
use strict
"
;
var
b
=
function
(){
var
a
=!
1
,
b
=
navigator
.
userAgent
.
match
(
/Chrom
(
e|ium
)\/([
0-9
]
+
)\.
/
);
return
b
&&
parseInt
(
b
[
2
],
10
)
<
54
&&
(
a
=!
0
),
a
},
c
=
{
scale
:
1
,
zoom
:
!
0
,
actualSize
:
!
0
,
enableZoomAfter
:
300
,
useLeftForZoom
:
b
()},
d
=
function
(
b
){
return
this
.
core
=
a
(
b
).
data
(
"
lightGallery
"
),
this
.
core
.
s
=
a
.
extend
({},
c
,
this
.
core
.
s
),
this
.
core
.
s
.
zoom
&&
this
.
core
.
doCss
()
&&
(
this
.
init
(),
this
.
zoomabletimeout
=!
1
,
this
.
pageX
=
a
(
window
).
width
()
/
2
,
this
.
pageY
=
a
(
window
).
height
()
/
2
+
a
(
window
).
scrollTop
()),
this
};
d
.
prototype
.
init
=
function
(){
var
b
=
this
,
c
=
'
<span id="lg-zoom-in" class="lg-icon"></span><span id="lg-zoom-out" class="lg-icon"></span>
'
;
b
.
core
.
s
.
actualSize
&&
(
c
+=
'
<span id="lg-actual-size" class="lg-icon"></span>
'
),
b
.
core
.
s
.
useLeftForZoom
?
b
.
core
.
$outer
.
addClass
(
"
lg-use-left-for-zoom
"
):
b
.
core
.
$outer
.
addClass
(
"
lg-use-transition-for-zoom
"
),
this
.
core
.
$outer
.
find
(
"
.lg-toolbar
"
).
append
(
c
),
b
.
core
.
$el
.
on
(
"
onSlideItemLoad.lg.tm.zoom
"
,
function
(
c
,
d
,
e
){
var
f
=
b
.
core
.
s
.
enableZoomAfter
+
e
;
a
(
"
body
"
).
hasClass
(
"
lg-from-hash
"
)
&&
e
?
f
=
0
:
a
(
"
body
"
).
removeClass
(
"
lg-from-hash
"
),
b
.
zoomabletimeout
=
setTimeout
(
function
(){
b
.
core
.
$slide
.
eq
(
d
).
addClass
(
"
lg-zoomable
"
)},
f
+
30
)});
var
d
=
1
,
e
=
function
(
c
){
var
d
,
e
,
f
=
b
.
core
.
$outer
.
find
(
"
.lg-current .lg-image
"
),
g
=
(
a
(
window
).
width
()
-
f
.
prop
(
"
offsetWidth
"
))
/
2
,
h
=
(
a
(
window
).
height
()
-
f
.
prop
(
"
offsetHeight
"
))
/
2
+
a
(
window
).
scrollTop
();
d
=
b
.
pageX
-
g
,
e
=
b
.
pageY
-
h
;
var
i
=
(
c
-
1
)
*
d
,
j
=
(
c
-
1
)
*
e
;
f
.
css
(
"
transform
"
,
"
scale3d(
"
+
c
+
"
,
"
+
c
+
"
, 1)
"
).
attr
(
"
data-scale
"
,
c
),
b
.
core
.
s
.
useLeftForZoom
?
f
.
parent
().
css
({
left
:
-
i
+
"
px
"
,
top
:
-
j
+
"
px
"
}).
attr
(
"
data-x
"
,
i
).
attr
(
"
data-y
"
,
j
):
f
.
parent
().
css
(
"
transform
"
,
"
translate3d(-
"
+
i
+
"
px, -
"
+
j
+
"
px, 0)
"
).
attr
(
"
data-x
"
,
i
).
attr
(
"
data-y
"
,
j
)},
f
=
function
(){
d
>
1
?
b
.
core
.
$outer
.
addClass
(
"
lg-zoomed
"
):
b
.
resetZoom
(),
d
<
1
&&
(
d
=
1
),
e
(
d
)},
g
=
function
(
c
,
e
,
g
,
h
){
var
i
,
j
=
e
.
prop
(
"
offsetWidth
"
);
i
=
b
.
core
.
s
.
dynamic
?
b
.
core
.
s
.
dynamicEl
[
g
].
width
||
e
[
0
].
naturalWidth
||
j
:
b
.
core
.
$items
.
eq
(
g
).
attr
(
"
data-width
"
)
||
e
[
0
].
naturalWidth
||
j
;
var
k
;
b
.
core
.
$outer
.
hasClass
(
"
lg-zoomed
"
)?
d
=
1
:
i
>
j
&&
(
k
=
i
/
j
,
d
=
k
||
2
),
h
?(
b
.
pageX
=
a
(
window
).
width
()
/
2
,
b
.
pageY
=
a
(
window
).
height
()
/
2
+
a
(
window
).
scrollTop
()):(
b
.
pageX
=
c
.
pageX
||
c
.
originalEvent
.
targetTouches
[
0
].
pageX
,
b
.
pageY
=
c
.
pageY
||
c
.
originalEvent
.
targetTouches
[
0
].
pageY
),
f
(),
setTimeout
(
function
(){
b
.
core
.
$outer
.
removeClass
(
"
lg-grabbing
"
).
addClass
(
"
lg-grab
"
)},
10
)},
h
=!
1
;
b
.
core
.
$el
.
on
(
"
onAferAppendSlide.lg.tm.zoom
"
,
function
(
a
,
c
){
var
d
=
b
.
core
.
$slide
.
eq
(
c
).
find
(
"
.lg-image
"
);
d
.
on
(
"
dblclick
"
,
function
(
a
){
g
(
a
,
d
,
c
)}),
d
.
on
(
"
touchstart
"
,
function
(
a
){
h
?(
clearTimeout
(
h
),
h
=
null
,
g
(
a
,
d
,
c
)):
h
=
setTimeout
(
function
(){
h
=
null
},
300
),
a
.
preventDefault
()})}),
a
(
window
).
on
(
"
resize.lg.zoom scroll.lg.zoom orientationchange.lg.zoom
"
,
function
(){
b
.
pageX
=
a
(
window
).
width
()
/
2
,
b
.
pageY
=
a
(
window
).
height
()
/
2
+
a
(
window
).
scrollTop
(),
e
(
d
)}),
a
(
"
#lg-zoom-out
"
).
on
(
"
click.lg
"
,
function
(){
b
.
core
.
$outer
.
find
(
"
.lg-current .lg-image
"
).
length
&&
(
d
-=
b
.
core
.
s
.
scale
,
f
())}),
a
(
"
#lg-zoom-in
"
).
on
(
"
click.lg
"
,
function
(){
b
.
core
.
$outer
.
find
(
"
.lg-current .lg-image
"
).
length
&&
(
d
+=
b
.
core
.
s
.
scale
,
f
())}),
a
(
"
#lg-actual-size
"
).
on
(
"
click.lg
"
,
function
(
a
){
g
(
a
,
b
.
core
.
$slide
.
eq
(
b
.
core
.
index
).
find
(
"
.lg-image
"
),
b
.
core
.
index
,
!
0
)}),
b
.
core
.
$el
.
on
(
"
onBeforeSlide.lg.tm
"
,
function
(){
d
=
1
,
b
.
resetZoom
()}),
b
.
core
.
isTouch
||
b
.
zoomDrag
(),
b
.
core
.
isTouch
&&
b
.
zoomSwipe
()},
d
.
prototype
.
resetZoom
=
function
(){
this
.
core
.
$outer
.
removeClass
(
"
lg-zoomed
"
),
this
.
core
.
$slide
.
find
(
"
.lg-img-wrap
"
).
removeAttr
(
"
style data-x data-y
"
),
this
.
core
.
$slide
.
find
(
"
.lg-image
"
).
removeAttr
(
"
style data-scale
"
),
this
.
pageX
=
a
(
window
).
width
()
/
2
,
this
.
pageY
=
a
(
window
).
height
()
/
2
+
a
(
window
).
scrollTop
()},
d
.
prototype
.
zoomSwipe
=
function
(){
var
a
=
this
,
b
=
{},
c
=
{},
d
=!
1
,
e
=!
1
,
f
=!
1
;
a
.
core
.
$slide
.
on
(
"
touchstart.lg
"
,
function
(
c
){
if
(
a
.
core
.
$outer
.
hasClass
(
"
lg-zoomed
"
)){
var
d
=
a
.
core
.
$slide
.
eq
(
a
.
core
.
index
).
find
(
"
.lg-object
"
);
f
=
d
.
prop
(
"
offsetHeight
"
)
*
d
.
attr
(
"
data-scale
"
)
>
a
.
core
.
$outer
.
find
(
"
.lg
"
).
height
(),
e
=
d
.
prop
(
"
offsetWidth
"
)
*
d
.
attr
(
"
data-scale
"
)
>
a
.
core
.
$outer
.
find
(
"
.lg
"
).
width
(),(
e
||
f
)
&&
(
c
.
preventDefault
(),
b
=
{
x
:
c
.
originalEvent
.
targetTouches
[
0
].
pageX
,
y
:
c
.
originalEvent
.
targetTouches
[
0
].
pageY
})}}),
a
.
core
.
$slide
.
on
(
"
touchmove.lg
"
,
function
(
g
){
if
(
a
.
core
.
$outer
.
hasClass
(
"
lg-zoomed
"
)){
var
h
,
i
,
j
=
a
.
core
.
$slide
.
eq
(
a
.
core
.
index
).
find
(
"
.lg-img-wrap
"
);
g
.
preventDefault
(),
d
=!
0
,
c
=
{
x
:
g
.
originalEvent
.
targetTouches
[
0
].
pageX
,
y
:
g
.
originalEvent
.
targetTouches
[
0
].
pageY
},
a
.
core
.
$outer
.
addClass
(
"
lg-zoom-dragging
"
),
i
=
f
?
-
Math
.
abs
(
j
.
attr
(
"
data-y
"
))
+
(
c
.
y
-
b
.
y
):
-
Math
.
abs
(
j
.
attr
(
"
data-y
"
)),
h
=
e
?
-
Math
.
abs
(
j
.
attr
(
"
data-x
"
))
+
(
c
.
x
-
b
.
x
):
-
Math
.
abs
(
j
.
attr
(
"
data-x
"
)),(
Math
.
abs
(
c
.
x
-
b
.
x
)
>
15
||
Math
.
abs
(
c
.
y
-
b
.
y
)
>
15
)
&&
(
a
.
core
.
s
.
useLeftForZoom
?
j
.
css
({
left
:
h
+
"
px
"
,
top
:
i
+
"
px
"
}):
j
.
css
(
"
transform
"
,
"
translate3d(
"
+
h
+
"
px,
"
+
i
+
"
px, 0)
"
))}}),
a
.
core
.
$slide
.
on
(
"
touchend.lg
"
,
function
(){
a
.
core
.
$outer
.
hasClass
(
"
lg-zoomed
"
)
&&
d
&&
(
d
=!
1
,
a
.
core
.
$outer
.
removeClass
(
"
lg-zoom-dragging
"
),
a
.
touchendZoom
(
b
,
c
,
e
,
f
))})},
d
.
prototype
.
zoomDrag
=
function
(){
var
b
=
this
,
c
=
{},
d
=
{},
e
=!
1
,
f
=!
1
,
g
=!
1
,
h
=!
1
;
b
.
core
.
$slide
.
on
(
"
mousedown.lg.zoom
"
,
function
(
d
){
var
f
=
b
.
core
.
$slide
.
eq
(
b
.
core
.
index
).
find
(
"
.lg-object
"
);
h
=
f
.
prop
(
"
offsetHeight
"
)
*
f
.
attr
(
"
data-scale
"
)
>
b
.
core
.
$outer
.
find
(
"
.lg
"
).
height
(),
g
=
f
.
prop
(
"
offsetWidth
"
)
*
f
.
attr
(
"
data-scale
"
)
>
b
.
core
.
$outer
.
find
(
"
.lg
"
).
width
(),
b
.
core
.
$outer
.
hasClass
(
"
lg-zoomed
"
)
&&
a
(
d
.
target
).
hasClass
(
"
lg-object
"
)
&&
(
g
||
h
)
&&
(
d
.
preventDefault
(),
c
=
{
x
:
d
.
pageX
,
y
:
d
.
pageY
},
e
=!
0
,
b
.
core
.
$outer
.
scrollLeft
+=
1
,
b
.
core
.
$outer
.
scrollLeft
-=
1
,
b
.
core
.
$outer
.
removeClass
(
"
lg-grab
"
).
addClass
(
"
lg-grabbing
"
))}),
a
(
window
).
on
(
"
mousemove.lg.zoom
"
,
function
(
a
){
if
(
e
){
var
i
,
j
,
k
=
b
.
core
.
$slide
.
eq
(
b
.
core
.
index
).
find
(
"
.lg-img-wrap
"
);
f
=!
0
,
d
=
{
x
:
a
.
pageX
,
y
:
a
.
pageY
},
b
.
core
.
$outer
.
addClass
(
"
lg-zoom-dragging
"
),
j
=
h
?
-
Math
.
abs
(
k
.
attr
(
"
data-y
"
))
+
(
d
.
y
-
c
.
y
):
-
Math
.
abs
(
k
.
attr
(
"
data-y
"
)),
i
=
g
?
-
Math
.
abs
(
k
.
attr
(
"
data-x
"
))
+
(
d
.
x
-
c
.
x
):
-
Math
.
abs
(
k
.
attr
(
"
data-x
"
)),
b
.
core
.
s
.
useLeftForZoom
?
k
.
css
({
left
:
i
+
"
px
"
,
top
:
j
+
"
px
"
}):
k
.
css
(
"
transform
"
,
"
translate3d(
"
+
i
+
"
px,
"
+
j
+
"
px, 0)
"
)}}),
a
(
window
).
on
(
"
mouseup.lg.zoom
"
,
function
(
a
){
e
&&
(
e
=!
1
,
b
.
core
.
$outer
.
removeClass
(
"
lg-zoom-dragging
"
),
!
f
||
c
.
x
===
d
.
x
&&
c
.
y
===
d
.
y
||
(
d
=
{
x
:
a
.
pageX
,
y
:
a
.
pageY
},
b
.
touchendZoom
(
c
,
d
,
g
,
h
)),
f
=!
1
),
b
.
core
.
$outer
.
removeClass
(
"
lg-grabbing
"
).
addClass
(
"
lg-grab
"
)})},
d
.
prototype
.
touchendZoom
=
function
(
a
,
b
,
c
,
d
){
var
e
=
this
,
f
=
e
.
core
.
$slide
.
eq
(
e
.
core
.
index
).
find
(
"
.lg-img-wrap
"
),
g
=
e
.
core
.
$slide
.
eq
(
e
.
core
.
index
).
find
(
"
.lg-object
"
),
h
=-
Math
.
abs
(
f
.
attr
(
"
data-x
"
))
+
(
b
.
x
-
a
.
x
),
i
=-
Math
.
abs
(
f
.
attr
(
"
data-y
"
))
+
(
b
.
y
-
a
.
y
),
j
=
(
e
.
core
.
$outer
.
find
(
"
.lg
"
).
height
()
-
g
.
prop
(
"
offsetHeight
"
))
/
2
,
k
=
Math
.
abs
(
g
.
prop
(
"
offsetHeight
"
)
*
Math
.
abs
(
g
.
attr
(
"
data-scale
"
))
-
e
.
core
.
$outer
.
find
(
"
.lg
"
).
height
()
+
j
),
l
=
(
e
.
core
.
$outer
.
find
(
"
.lg
"
).
width
()
-
g
.
prop
(
"
offsetWidth
"
))
/
2
,
m
=
Math
.
abs
(
g
.
prop
(
"
offsetWidth
"
)
*
Math
.
abs
(
g
.
attr
(
"
data-scale
"
))
-
e
.
core
.
$outer
.
find
(
"
.lg
"
).
width
()
+
l
);(
Math
.
abs
(
b
.
x
-
a
.
x
)
>
15
||
Math
.
abs
(
b
.
y
-
a
.
y
)
>
15
)
&&
(
d
&&
(
i
<=-
k
?
i
=-
k
:
i
>=-
j
&&
(
i
=-
j
)),
c
&&
(
h
<=-
m
?
h
=-
m
:
h
>=-
l
&&
(
h
=-
l
)),
d
?
f
.
attr
(
"
data-y
"
,
Math
.
abs
(
i
)):
i
=-
Math
.
abs
(
f
.
attr
(
"
data-y
"
)),
c
?
f
.
attr
(
"
data-x
"
,
Math
.
abs
(
h
)):
h
=-
Math
.
abs
(
f
.
attr
(
"
data-x
"
)),
e
.
core
.
s
.
useLeftForZoom
?
f
.
css
({
left
:
h
+
"
px
"
,
top
:
i
+
"
px
"
}):
f
.
css
(
"
transform
"
,
"
translate3d(
"
+
h
+
"
px,
"
+
i
+
"
px, 0)
"
))},
d
.
prototype
.
destroy
=
function
(){
var
b
=
this
;
b
.
core
.
$el
.
off
(
"
.lg.zoom
"
),
a
(
window
).
off
(
"
.lg.zoom
"
),
b
.
core
.
$slide
.
off
(
"
.lg.zoom
"
),
b
.
core
.
$el
.
off
(
"
.lg.tm.zoom
"
),
b
.
resetZoom
(),
clearTimeout
(
b
.
zoomabletimeout
),
b
.
zoomabletimeout
=!
1
},
a
.
fn
.
lightGallery
.
modules
.
zoom
=
d
}()});
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment