Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rocket.Chat
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RocketChat
Rocket.Chat
Commits
e4bfde3c
Unverified
Commit
e4bfde3c
authored
2 years ago
by
gabriellsh
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fix: Gallery opening other image after closing (#27957)
parent
b090d225
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/meteor/app/ui/client/views/app/photoswipeContent.ts
+43
-31
43 additions, 31 deletions
apps/meteor/app/ui/client/views/app/photoswipeContent.ts
with
43 additions
and
31 deletions
apps/meteor/app/ui/client/views/app/photoswipeContent.ts
+
43
−
31
View file @
e4bfde3c
...
...
@@ -79,7 +79,7 @@ const initGallery = async (items: Slide[], options: PhotoSwipe.Options): Promise
import
(
'
./photoswipeContent.html
'
),
]);
Blaze
.
render
(
Template
.
photoswipeContent
,
document
.
body
);
const
view
=
Blaze
.
render
(
Template
.
photoswipeContent
,
document
.
body
);
if
(
!
currentGallery
)
{
const
container
=
document
.
getElementById
(
'
pswp
'
);
...
...
@@ -91,6 +91,7 @@ const initGallery = async (items: Slide[], options: PhotoSwipe.Options): Promise
currentGallery
=
new
PhotoSwipe
(
container
,
PhotoSwipeUIDefault
,
items
,
options
);
currentGallery
.
listen
(
'
destroy
'
,
()
=>
{
Blaze
.
remove
(
view
);
currentGallery
=
null
;
});
...
...
@@ -121,38 +122,49 @@ const createEventListenerFor =
const
{
currentTarget
}
=
event
;
Array
.
from
(
document
.
querySelectorAll
(
className
))
.
sort
((
a
,
b
)
=>
{
if
(
a
===
currentTarget
)
{
return
-
1
;
}
if
(
b
===
currentTarget
)
{
return
1
;
}
return
0
;
})
.
map
((
element
)
=>
fromElementToSlide
(
element
))
.
reduce
(
(
p
,
curr
)
=>
p
.
then
(()
=>
curr
)
.
then
(
async
(
slide
)
=>
{
if
(
!
slide
)
{
return
;
}
const
galleryItems
=
Array
.
from
(
document
.
querySelectorAll
(
className
));
if
(
!
currentGallery
)
{
return
initGallery
([
slide
],
defaultGalleryOptions
);
}
const
sortedElements
=
galleryItems
.
sort
((
a
,
b
)
=>
{
if
(
a
===
currentTarget
)
{
return
-
1
;
}
currentGallery
.
items
.
push
(
slide
);
currentGallery
.
invalidateCurrItems
();
currentGallery
.
updateSize
(
true
);
}),
Promise
.
resolve
(),
);
if
(
b
===
currentTarget
)
{
return
1
;
}
return
0
;
});
const
slidePromises
=
sortedElements
.
map
((
element
)
=>
fromElementToSlide
(
element
));
let
hasOpenedGallery
=
false
;
slidePromises
.
reduce
(
(
p
,
curr
)
=>
p
.
then
(()
=>
curr
)
.
then
(
async
(
slide
)
=>
{
if
(
!
slide
)
{
return
;
}
if
(
!
currentGallery
)
{
// If the gallery doesn't exist and has been opened this run the user closed it before all promises ran.
// This means it shouldn't be opened again.
if
(
hasOpenedGallery
)
{
return
;
}
hasOpenedGallery
=
true
;
return
initGallery
([
slide
],
defaultGalleryOptions
);
}
currentGallery
.
items
.
push
(
slide
);
currentGallery
.
invalidateCurrItems
();
currentGallery
.
updateSize
(
true
);
}),
Promise
.
resolve
(),
);
};
Meteor
.
startup
(()
=>
{
...
...
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