BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
34462621
Commit
34462621
authored
Sep 22, 2017
by
Fatih Acet
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'emoji-dom-size' into 'master'
Improve emoji menu rendering performance Closes #36949 See merge request gitlab-org/gitlab-ce!14233
parents
c8e60d63
014bbe65
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
6 deletions
+43
-6
awards_handler.js
app/assets/javascripts/awards_handler.js
+38
-6
awards.scss
app/assets/stylesheets/framework/awards.scss
+5
-0
No files found.
app/assets/javascripts/awards_handler.js
View file @
34462621
...
...
@@ -24,6 +24,9 @@ const categoryLabelMap = {
flags
:
'Flags'
,
};
const
IS_VISIBLE
=
'is-visible'
;
const
IS_RENDERED
=
'is-rendered'
;
class
AwardsHandler
{
constructor
(
emoji
)
{
this
.
emoji
=
emoji
;
...
...
@@ -51,7 +54,7 @@ class AwardsHandler {
if
(
!
$target
.
closest
(
'.emoji-menu'
).
length
)
{
if
(
$
(
'.emoji-menu'
).
is
(
':visible'
))
{
$
(
'.js-add-award.is-active'
).
removeClass
(
'is-active'
);
$
(
'.emoji-menu'
).
removeClass
(
'is-visible'
);
this
.
hideMenuElement
(
$
(
'.emoji-menu'
)
);
}
}
});
...
...
@@ -88,12 +91,12 @@ class AwardsHandler {
if
(
$menu
.
length
)
{
if
(
$menu
.
is
(
'.is-visible'
))
{
$addBtn
.
removeClass
(
'is-active'
);
$menu
.
removeClass
(
'is-visible'
);
this
.
hideMenuElement
(
$menu
);
$
(
'.js-emoji-menu-search'
).
blur
();
}
else
{
$addBtn
.
addClass
(
'is-active'
);
this
.
positionMenu
(
$menu
,
$addBtn
);
$menu
.
addClass
(
'is-visible'
);
this
.
showMenuElement
(
$menu
);
$
(
'.js-emoji-menu-search'
).
focus
();
}
}
else
{
...
...
@@ -103,7 +106,7 @@ class AwardsHandler {
$addBtn
.
removeClass
(
'is-loading'
);
this
.
positionMenu
(
$createdMenu
,
$addBtn
);
return
setTimeout
(()
=>
{
$createdMenu
.
addClass
(
'is-visible'
);
this
.
showMenuElement
(
$createdMenu
);
$
(
'.js-emoji-menu-search'
).
focus
();
},
200
);
});
...
...
@@ -241,7 +244,8 @@ class AwardsHandler {
if
(
isInIssuePage
()
&&
!
isMainAwardsBlock
)
{
const
id
=
votesBlock
.
attr
(
'id'
).
replace
(
'note_'
,
''
);
$
(
'.emoji-menu'
).
removeClass
(
'is-visible'
);
this
.
hideMenuElement
(
$
(
'.emoji-menu'
));
$
(
'.js-add-award.is-active'
).
removeClass
(
'is-active'
);
const
toggleAwardEvent
=
new
CustomEvent
(
'toggleAward'
,
{
detail
:
{
...
...
@@ -261,7 +265,8 @@ class AwardsHandler {
return
typeof
callback
===
'function'
?
callback
()
:
undefined
;
});
$
(
'.emoji-menu'
).
removeClass
(
'is-visible'
);
this
.
hideMenuElement
(
$
(
'.emoji-menu'
));
return
$
(
'.js-add-award.is-active'
).
removeClass
(
'is-active'
);
}
...
...
@@ -529,6 +534,33 @@ class AwardsHandler {
return
$matchingElements
.
closest
(
'li'
).
clone
();
}
/* showMenuElement and hideMenuElement are performance optimizations. We use
* opacity to show/hide the emoji menu, because we can animate it. But opacity
* leaves hidden elements in the render tree, which is unacceptable given the number
* of emoji elements in the emoji menu (5k+). To get the best of both worlds, we separately
* apply IS_RENDERED to add/remove the menu from the render tree and IS_VISIBLE to animate
* the menu being opened and closed. */
showMenuElement
(
$emojiMenu
)
{
$emojiMenu
.
addClass
(
IS_RENDERED
);
// enqueues animation as a microtask, so it begins ASAP once IS_RENDERED added
return
Promise
.
resolve
()
.
then
(()
=>
$emojiMenu
.
addClass
(
IS_VISIBLE
));
}
hideMenuElement
(
$emojiMenu
)
{
$emojiMenu
.
on
(
transitionEndEventString
,
(
e
)
=>
{
if
(
e
.
currentTarget
===
e
.
target
)
{
$emojiMenu
.
removeClass
(
IS_RENDERED
)
.
off
(
transitionEndEventString
);
}
});
$emojiMenu
.
removeClass
(
IS_VISIBLE
);
}
destroy
()
{
this
.
eventListeners
.
forEach
((
entry
)
=>
{
entry
.
element
.
off
.
call
(
entry
.
element
,
...
entry
.
args
);
...
...
app/assets/stylesheets/framework/awards.scss
View file @
34462621
...
...
@@ -9,6 +9,7 @@
}
.emoji-menu
{
display
:
none
;
position
:
absolute
;
top
:
0
;
margin-top
:
3px
;
...
...
@@ -27,6 +28,10 @@
transition
:
.3s
cubic-bezier
(
.67
,
.06
,
.19
,
1
.44
);
transition-property
:
transform
,
opacity
;
&
.is-rendered
{
display
:
block
;
}
&
.is-aligned-right
{
transform-origin
:
100%
-45px
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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