Skip to content

Commit

Permalink
- Enhancement: new state classs "fp-loaded" for lazy loaded sections #…
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarotrigo committed Mar 3, 2025
1 parent 890db79 commit 80bcdcb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/js/common/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export const ACTIVE = 'active';
export const ACTIVE_SEL = '.' + ACTIVE;
export const COMPLETELY = 'fp-completely';
export const COMPLETELY_SEL = '.' + COMPLETELY;
export const LOADED = 'fp-loaded';
export const LOADED_SEL = '.' + LOADED;

// section
export const SECTION_DEFAULT_SEL = '.section';
Expand Down
5 changes: 3 additions & 2 deletions src/js/dom/destroyStructure.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import {
IS_OVERFLOW,
SCROLLABLE,
WRAPPER,
WATERMARK_SEL
WATERMARK_SEL,
LOADED
} from '../common/selectors.js';
import { win } from '../common/constants.js';
import { scrollOverflowHandler } from '../scrolloverflow.js';
Expand Down Expand Up @@ -89,7 +90,7 @@ export function destroyStructure(){
scrollOverflowHandler.destroyWrapper(item);
}

utils.removeClass(item, TABLE + ' ' + ACTIVE + ' ' + COMPLETELY + ' ' + IS_OVERFLOW);
utils.removeClass(item, TABLE + ' ' + ACTIVE + ' ' + COMPLETELY + ' ' + IS_OVERFLOW + ' ' + LOADED);
var previousStyles = utils.getAttr(item, 'data-fp-styles');
if(previousStyles){
item.setAttribute('style', previousStyles);
Expand Down
5 changes: 5 additions & 0 deletions src/js/lazyLoad/lazyLoad.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import * as utils from '../common/utils.js';
import { getSlideOrSection } from '../common/utilsFP.js';
import { getOptions } from '../common/options.js';
import { onMediaLoad } from '../media.js';
import { LOADED } from '../common/selectors.js';

/**
* Lazy loads image, video and audio elements.
*/
Expand Down Expand Up @@ -33,6 +35,9 @@ export function lazyLoad(destiny){
}
}
});

// Add fp-loaded class to the panel after lazy loading
utils.addClass(panel, LOADED);
}

export function lazyLoadPanels(panel){
Expand Down

0 comments on commit 80bcdcb

Please sign in to comment.