Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
photoswipe-3381407
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
photoswipe-3381407
Commits
dd5baec9
Commit
dd5baec9
authored
6 years ago
by
Julian Pustkuchen
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2891337
by amanire, Anybody: Zoom animation (Drupal 8)
parent
0f32c498
No related branches found
Branches containing commit
Tags
8.x-2.4
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
js/photoswipe.jquery.js
+26
-14
26 additions, 14 deletions
js/photoswipe.jquery.js
with
26 additions
and
14 deletions
js/photoswipe.jquery.js
+
26
−
14
View file @
dd5baec9
...
...
@@ -15,12 +15,12 @@
this
.
photoSwipeOptions
=
settings
.
photoswipe
?
settings
.
photoswipe
.
options
:
{};
// First ensure all photoswipe photos are in a photoswipe-gallery wrapper:
var
$imagesWithoutGalleries
=
$
(
'
a.photoswipe
'
,
context
).
filter
(
function
(
elem
)
{
var
$imagesWithoutGalleries
=
$
(
'
a.photoswipe
'
,
context
).
filter
(
function
(
elem
)
{
return
!
$
(
this
).
parents
(
'
.photoswipe-gallery
'
).
length
;
});
if
(
$imagesWithoutGalleries
.
length
)
{
// We have no galleries just individual images.
$imagesWithoutGalleries
.
each
(
function
(
index
)
{
$imagesWithoutGalleries
.
each
(
function
(
index
)
{
$imageLink
=
$
(
this
);
// Add the wrapper and indicate that it's an automatic fallback:
$imageLink
.
wrap
(
'
<span class="photoswipe-gallery photoswipe-gallery--fallback-wrapper"></span>
'
);
...
...
@@ -30,7 +30,7 @@
var
$galleries
=
$
(
'
.photoswipe-gallery
'
,
context
);
if
(
$galleries
.
length
)
{
// if body haven't special container for show photoswipe gallery append it.
if
(
'
container
'
in
settings
.
photoswipe
&&
!
$
(
'
.pswp
'
).
length
){
if
(
'
container
'
in
settings
.
photoswipe
&&
!
$
(
'
.pswp
'
).
length
)
{
$
(
'
body
'
).
append
(
settings
.
photoswipe
.
container
);
}
...
...
@@ -46,8 +46,8 @@
// Parse URL and open gallery if it contains #&pid=3&gid=1
var
hashData
=
this
.
parseHash
();
if
(
hashData
.
pid
>
0
&&
hashData
.
gid
>
0
)
{
this
.
openPhotoSwipe
(
hashData
.
pid
-
1
,
$
(
$galleries
[
hashData
.
gid
-
1
]));
if
(
hashData
.
pid
>
0
&&
hashData
.
gid
>
0
)
{
this
.
openPhotoSwipe
(
hashData
.
pid
-
1
,
$
(
$galleries
[
hashData
.
gid
-
1
]));
}
},
/**
...
...
@@ -56,7 +56,7 @@
* Code taken from http://photoswipe.com/documentation/getting-started.html
* and adjusted accordingly.
*/
onThumbnailsClick
:
function
(
e
)
{
onThumbnailsClick
:
function
(
e
)
{
e
=
e
||
window
.
event
;
var
$clickedGallery
=
$
(
this
);
var
eTarget
=
e
.
target
||
e
.
srcElement
;
...
...
@@ -82,7 +82,7 @@
* Code taken from http://photoswipe.com/documentation/getting-started.html
* and adjusted accordingly.
*/
openPhotoSwipe
:
function
(
index
,
galleryElement
,
options
)
{
openPhotoSwipe
:
function
(
index
,
galleryElement
,
options
)
{
var
pswpElement
=
$
(
'
.pswp
'
)[
0
];
var
items
=
[];
options
=
options
||
Drupal
.
behaviors
.
photoswipe
.
photoSwipeOptions
;
...
...
@@ -90,13 +90,14 @@
var
images
=
galleryElement
.
find
(
'
a.photoswipe
'
);
images
.
each
(
function
(
index
)
{
var
$image
=
$
(
this
);
size
=
$image
.
data
(
'
size
'
)
?
$image
.
data
(
'
size
'
).
split
(
'
x
'
)
:
[
''
,
''
];
size
=
$image
.
data
(
'
size
'
)
?
$image
.
data
(
'
size
'
).
split
(
'
x
'
)
:
[
''
,
''
];
items
.
push
(
{
src
:
$image
.
attr
(
'
href
'
),
src
:
$image
.
attr
(
'
href
'
),
w
:
size
[
0
],
h
:
size
[
1
],
title
:
$image
.
data
(
'
overlay-title
'
)
title
:
$image
.
data
(
'
overlay-title
'
),
msrc
:
$image
.
find
(
'
img
'
).
attr
(
'
src
'
)
}
);
})
...
...
@@ -106,6 +107,17 @@
// define gallery index (for URL)
options
.
galleryUID
=
galleryElement
.
data
(
'
pswp-uid
'
);
// Add zoom animation function:
options
.
getThumbBoundsFn
=
function
(
index
)
{
var
tn
=
galleryElement
.
find
(
'
a.photoswipe:eq(
'
+
index
+
'
) img
'
);
if
(
tn
.
length
==
0
)
{
tn
=
galleryElement
.
find
(
'
a.photoswipe:eq(0) img
'
);
}
var
tw
=
tn
.
width
();
var
tpos
=
tn
.
offset
();
return
{
x
:
tpos
.
left
,
y
:
tpos
.
top
,
w
:
tw
};
}
// Pass data to PhotoSwipe and initialize it
var
gallery
=
new
PhotoSwipe
(
pswpElement
,
PhotoSwipeUI_Default
,
items
,
options
);
gallery
.
init
();
...
...
@@ -117,9 +129,9 @@
* Code taken from http://photoswipe.com/documentation/getting-started.html
* and adjusted accordingly.
*/
parseHash
:
function
()
{
parseHash
:
function
()
{
var
hash
=
window
.
location
.
hash
.
substring
(
1
),
params
=
{};
params
=
{};
if
(
hash
.
length
<
5
)
{
return
params
;
...
...
@@ -137,11 +149,11 @@
params
[
pair
[
0
]]
=
pair
[
1
];
}
if
(
params
.
gid
)
{
if
(
params
.
gid
)
{
params
.
gid
=
parseInt
(
params
.
gid
,
10
);
}
if
(
!
params
.
hasOwnProperty
(
'
pid
'
))
{
if
(
!
params
.
hasOwnProperty
(
'
pid
'
))
{
return
params
;
}
params
.
pid
=
parseInt
(
params
.
pid
,
10
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment