PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.2
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.2
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
learnpress / assets / src / apps / js / frontend / single-curriculum / scrolltoitem.js

scrolltoitem.js in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.4.2, at assets/src/apps/js/frontend/single-curriculum/scrolltoitem.js

48 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import lpModalOverlay from '../../utils/lp-modal-overlay';
2
3 const $ = jQuery;
4
5 const scrollToItemCurrent = {
6 init() {
7 this.scrollToItemViewing = function() {
8 const elItemViewing = $( '.viewing-course-item' );
9 if ( elItemViewing.length ) {
10 const elCourseCurriculumn = $( '#learn-press-course-curriculum' );
11 const heightCourseItemContentHeader = $( '#popup-sidebar' ).outerHeight();
12 const heightSectionTitle = $( '.section-title' ).outerHeight();
13 const heightSectionHeader = $( '.section-header' ).outerHeight();
14 const regex = new RegExp( '^viewing-course-item-([0-9].*)' );
15 const classList = elItemViewing.attr( 'class' );
16 const classArr = classList.split( /\s+/ );
17 let idItem = 0;
18
19 $.each( classArr, function( i, className ) {
20 const compare = regex.exec( className );
21
22 if ( compare ) {
23 idItem = compare[ 1 ];
24 return false;
25 }
26 } );
27
28 if ( 0 === idItem ) {
29 return;
30 }
31
32 const elItemCurrent = $( '.course-item-' + idItem );
33 elItemCurrent.addClass( 'current' );
34 const offSetTop = elItemCurrent.offset().top;
35 const offset = elItemCurrent.offset().top - elCourseCurriculumn.offset().top +
36 elCourseCurriculumn.scrollTop();
37
38 elCourseCurriculumn.animate( {
39 scrollTop: LP.Hook.applyFilters( 'scroll-item-current', offset - heightSectionHeader ),
40 }, 800 );
41 }
42 };
43 this.scrollToItemViewing();
44 },
45 };
46
47 export default scrollToItemCurrent;
48