Skip to content

Commit 42c178d

Browse files
author
Eddie-Thuo
committed
feat: trigger pulse effect on arrow shortcuts
1 parent 8b032a5 commit 42c178d

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

mp4-video-player.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ class MP4VideoPlayer extends PolymerElement {
1919
<div class="title">
2020
<h3 id="video_title">[[title]]</h3>
2121
</div>
22-
<div class="pulse-icon icon-left">
22+
<div id="replay_pulse" class="pulse-icon icon-left">
2323
<iron-icon icon="player-icons:replay-5"></iron-icon>
2424
</div>
25-
<div class="pulse-icon icon-right">
25+
<div id="forward_pulse" class="pulse-icon icon-right">
2626
<iron-icon icon="player-icons:forward-5"></iron-icon>
2727
</div>
2828
<div class="large-btn" on-click="play">
@@ -650,6 +650,8 @@ class MP4VideoPlayer extends PolymerElement {
650650
const maxVol = 1;
651651
const minVol = 0;
652652
const { currentTime, volume } = this._getShadowElementById('video_player');
653+
const forwardPulse = this._getShadowElementById('forward_pulse');
654+
const replayPulse = this._getShadowElementById('replay_pulse');
653655
switch (event.keyCode) {
654656
case this._SPACE_BAR_KEY:
655657
case this._P_KEY:
@@ -663,10 +665,18 @@ class MP4VideoPlayer extends PolymerElement {
663665
break;
664666
case this._LEFT_ARROW: {
665667
this._updateCurrentTime(currentTime - this.skipBy);
668+
replayPulse.classList.remove('on');
669+
// eslint-disable-next-line no-unused-expressions
670+
replayPulse.offsetWidth; // trigger reflow..
671+
replayPulse.classList.add('on');
666672
break;
667673
}
668674
case this._RIGHT_ARROW: {
669675
this._updateCurrentTime(currentTime + this.skipBy);
676+
forwardPulse.classList.remove('on');
677+
// eslint-disable-next-line no-unused-expressions
678+
forwardPulse.offsetWidth; // trigger reflow..
679+
forwardPulse.classList.add('on');
670680
break;
671681
}
672682
case this._UP_ARROW: {

player-styles.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ const playerStyles = html`
3333
height: 100px;
3434
border-radius: 50%;
3535
margin-top: -50px;
36-
background: red;
36+
background: var(--video-pulse-icon-color, #d32f2f);
37+
transform: scale(0);
3738
box-shadow: 0 0 0 0 rgba(224,20,20, 1);
38-
animation: pulse 1s ease-out;
39-
animation-iteration-count: infinite;
4039
}
4140
4241
.pulse-icon.icon-left {
@@ -57,6 +56,10 @@ const playerStyles = html`
5756
transform: translate(-50%, -50%);
5857
}
5958
59+
.pulse-icon.on {
60+
animation: pulse 0.55s ease-out;
61+
}
62+
6063
@keyframes pulse {
6164
0% {
6265
transform: scale(0.1, 0.1);

test/mp4-video-player_test.html

+8-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,8 @@
329329
'--video-menu-item-color': 'Cyan',
330330
'--video-menu-item-icon-color': 'DarkViolet',
331331
'--video-tooltip-background-color': 'Magenta',
332-
'--video-large-play-button-color': 'Azure'
332+
'--video-large-play-button-color': 'Azure',
333+
'--video-pulse-icon-color': 'LightSteelBlue'
333334
});
334335

335336
assertComputed(player, '750px', '--video-min-width');
@@ -361,6 +362,12 @@
361362

362363
const largePlayBtn = player.shadowRoot.querySelector('.tooltip');
363364
assertComputed(largePlayBtn, 'Azure', '--video-large-play-button-color');
365+
366+
const forwardPulse = player.shadowRoot.querySelector('#forward_pulse');
367+
assertComputed(forwardPulse, 'LightSteelBlue', '--video-pulse-icon-color');
368+
369+
const replayPulse = player.shadowRoot.querySelector('#replay_pulse');
370+
assertComputed(replayPulse, 'LightSteelBlue', '--video-pulse-icon-color');
364371
});
365372
});
366373

0 commit comments

Comments
 (0)