@@ -20,6 +20,8 @@ import dom from '../../utils/dom';
2020import './style.scss' ;
2121import 'material-design-icons-iconfont' ;
2222import '../../elements/emby-button/paper-icon-button-light' ;
23+ import { getIcon } from './slideshowhelper' ;
24+ import ZoomControl from './zoomControl' ;
2325
2426/**
2527 * Name of transition event.
@@ -106,20 +108,6 @@ function getImgUrl(item, user) {
106108 }
107109}
108110
109- /**
110- * Generates a button using the specified icon, classes and properties.
111- * @param {string } icon - Name of the material icon on the button
112- * @param {string } cssClass - CSS classes to assign to the button
113- * @param {boolean } canFocus - Flag to set the tabindex attribute on the button to -1.
114- * @param {boolean } autoFocus - Flag to set the autofocus attribute on the button.
115- * @returns {string } The HTML markup of the button.
116- */
117- function getIcon ( icon , cssClass , canFocus , autoFocus ) {
118- const tabIndex = canFocus ? '' : ' tabindex="-1"' ;
119- autoFocus = autoFocus ? ' autofocus' : '' ;
120- return '<button is="paper-icon-button-light" class="autoSize ' + cssClass + '"' + tabIndex + autoFocus + '><span class="material-icons slideshowButtonIcon ' + icon + '" aria-hidden="true"></span></button>' ;
121- }
122-
123111/**
124112 * Sets the viewport meta tag to enable or disable scaling by the user.
125113 * @param {boolean } scalable - Flag to set the scalability of the viewport.
@@ -144,6 +132,8 @@ export default function (options) {
144132 let hideTimeout ;
145133 /** Last coordinates of the mouse pointer. */
146134 let lastMouseMoveData ;
135+ /** Instance of zoom control **/
136+ let zoomControl ;
147137
148138 /**
149139 * Creates the HTML markup for the dialog and the OSD.
@@ -193,18 +183,23 @@ export default function (options) {
193183
194184 if ( ! actionButtonsOnTop ) {
195185 html += '<div class="slideshowBottomBar hide">' ;
196-
186+ html += '<div class="slideshowBottomBarLeft">' ;
197187 html += getIcon ( 'play_arrow' , 'btnSlideshowPause slideshowButton' , true , true ) ;
198188 if ( appHost . supports ( AppFeature . FileDownload ) && slideshowOptions ?. user . Policy . EnableContentDownloading ) {
199189 html += getIcon ( 'file_download' , 'btnDownload slideshowButton' , true ) ;
200190 }
201191 if ( appHost . supports ( AppFeature . Sharing ) ) {
202192 html += getIcon ( 'share' , 'btnShare slideshowButton' , true ) ;
203193 }
194+ html += '</div>' ;
195+
196+ html += '<div class="slideshowBottomBarRight">' ;
197+ html += ZoomControl . getHtml ( ) ;
204198 if ( screenfull . isEnabled ) {
205199 html += getIcon ( 'fullscreen' , 'btnFullscreen' , true ) ;
206200 html += getIcon ( 'fullscreen_exit' , 'btnFullscreenExit hide' , true ) ;
207201 }
202+ html += '</div>' ;
208203
209204 html += '</div>' ;
210205 }
@@ -306,31 +301,26 @@ export default function (options) {
306301 const zoomImage = slideEl . querySelector ( '.swiper-zoom-fakeimg' ) ;
307302
308303 if ( zoomImage ) {
304+ zoomImage . classList . add ( 'swiper-zoom-fakeimg-hidden' ) ;
309305 zoomImage . style . width = zoomImage . style . height = scale * 100 + '%' ;
310306
311- if ( scale > 1 ) {
312- if ( zoomImage . classList . contains ( 'swiper-zoom-fakeimg-hidden' ) ) {
313- // Await for Swiper style changes
314- setTimeout ( ( ) => {
315- const callback = ( ) => {
316- imageEl . removeEventListener ( transitionEndEventName , callback ) ;
317- zoomImage . classList . remove ( 'swiper-zoom-fakeimg-hidden' ) ;
318- } ;
319-
320- // Swiper set 'transition-duration: 300ms' for auto zoom
321- // and 'transition-duration: 0s' for touch zoom
322- const transitionDuration = parseFloat ( imageEl . style . transitionDuration . replace ( / [ a - z ] / i, '' ) ) ;
323-
324- if ( transitionDuration > 0 ) {
325- imageEl . addEventListener ( transitionEndEventName , callback ) ;
326- } else {
327- callback ( ) ;
328- }
329- } , 0 ) ;
307+ // Await for Swiper style changes
308+ setTimeout ( ( ) => {
309+ const callback = ( ) => {
310+ imageEl . removeEventListener ( transitionEndEventName , callback ) ;
311+ zoomImage . classList . remove ( 'swiper-zoom-fakeimg-hidden' ) ;
312+ } ;
313+
314+ // Swiper set 'transition-duration: 300ms' for auto zoom
315+ // and 'transition-duration: 0s' for touch zoom
316+ const transitionDuration = parseFloat ( imageEl . style . transitionDuration . replace ( / [ a - z ] / i, '' ) ) ;
317+
318+ if ( transitionDuration > 0 ) {
319+ imageEl . addEventListener ( transitionEndEventName , callback ) ;
320+ } else {
321+ callback ( ) ;
330322 }
331- } else {
332- zoomImage . classList . add ( 'swiper-zoom-fakeimg-hidden' ) ;
333- }
323+ } , 0 ) ;
334324 }
335325 }
336326
@@ -353,6 +343,7 @@ export default function (options) {
353343 // eslint-disable-next-line import/no-unresolved
354344 import ( 'swiper/bundle' ) . then ( ( { Swiper } ) => {
355345 swiperInstance = new Swiper ( dialogElement . querySelector ( '.slideshowSwiperContainer' ) , {
346+ init : false ,
356347 direction : 'horizontal' ,
357348 // Loop is disabled due to the virtual slides option not supporting it.
358349 loop : false ,
@@ -390,6 +381,10 @@ export default function (options) {
390381 swiperInstance . on ( 'zoomChange' , onZoomChange ) ;
391382 }
392383
384+ zoomControl = new ZoomControl ( dialogElement , swiperInstance , slides ) ;
385+ zoomControl . bindEvents ( ) ;
386+ swiperInstance . init ( ) ;
387+
393388 if ( swiperInstance . autoplay ?. running ) onAutoplayStart ( ) ;
394389 } ) ;
395390 }
0 commit comments