Skip to content

Commit

Permalink
[FEATURE] Add an option to make the zoom indicator optional
Browse files Browse the repository at this point in the history
Related: #62
  • Loading branch information
deoostfrees committed Aug 22, 2024
1 parent abdab7e commit e65d5c7
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 13 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ Available options include:
// Selector for a group of elements combined as a gallery, overrides the `data-group` attribute.
gallerySelector: null,

// Display zoom indicator
zoomIndicator: true,

// Display captions if available
captions: true,

Expand Down
11 changes: 7 additions & 4 deletions dist/js/parvus.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ function Parvus(userOptions) {
const DEFAULT_OPTIONS = {
selector: '.lightbox',
gallerySelector: null,
zoomIndicator: true,
captions: true,
captionsSelector: 'self',
captionsAttribute: 'data-caption',
Expand Down Expand Up @@ -203,7 +204,9 @@ function Parvus(userOptions) {
throw new Error('Ups, element already added.');
}
GROUPS[newGroup].triggerElements.push(el);
addZoomIndicator(el, config);
if (config.zoomIndicator) {
addZoomIndicator(el, config);
}
el.classList.add('parvus-trigger');
el.addEventListener('click', triggerParvus);
if (isOpen() && newGroup === activeGroup) {
Expand Down Expand Up @@ -236,9 +239,9 @@ function Parvus(userOptions) {
const EL_INDEX = GROUPS[EL_GROUP].triggerElements.indexOf(el);
GROUPS[EL_GROUP].triggerElements.splice(EL_INDEX, 1);
GROUPS[EL_GROUP].sliderElements.splice(EL_INDEX, 1);

// Remove lightbox indicator icon
removeZoomIndicator(el);
if (config.zoomIndicator) {
removeZoomIndicator(el);
}
if (isOpen() && EL_GROUP === activeGroup) {
updateAttributes();
updateSliderNavigationStatus();
Expand Down
2 changes: 1 addition & 1 deletion dist/js/parvus.esm.min.js

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions dist/js/parvus.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
const DEFAULT_OPTIONS = {
selector: '.lightbox',
gallerySelector: null,
zoomIndicator: true,
captions: true,
captionsSelector: 'self',
captionsAttribute: 'data-caption',
Expand Down Expand Up @@ -209,7 +210,9 @@
throw new Error('Ups, element already added.');
}
GROUPS[newGroup].triggerElements.push(el);
addZoomIndicator(el, config);
if (config.zoomIndicator) {
addZoomIndicator(el, config);
}
el.classList.add('parvus-trigger');
el.addEventListener('click', triggerParvus);
if (isOpen() && newGroup === activeGroup) {
Expand Down Expand Up @@ -242,9 +245,9 @@
const EL_INDEX = GROUPS[EL_GROUP].triggerElements.indexOf(el);
GROUPS[EL_GROUP].triggerElements.splice(EL_INDEX, 1);
GROUPS[EL_GROUP].sliderElements.splice(EL_INDEX, 1);

// Remove lightbox indicator icon
removeZoomIndicator(el);
if (config.zoomIndicator) {
removeZoomIndicator(el);
}
if (isOpen() && EL_GROUP === activeGroup) {
updateAttributes();
updateSliderNavigationStatus();
Expand Down
2 changes: 1 addition & 1 deletion dist/js/parvus.min.js

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions src/js/parvus.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default function Parvus (userOptions) {
const DEFAULT_OPTIONS = {
selector: '.lightbox',
gallerySelector: null,
zoomIndicator: true,
captions: true,
captionsSelector: 'self',
captionsAttribute: 'data-caption',
Expand Down Expand Up @@ -151,7 +152,9 @@ export default function Parvus (userOptions) {

GROUPS[newGroup].triggerElements.push(el)

addZoomIndicator(el, config)
if (config.zoomIndicator) {
addZoomIndicator(el, config)
}

el.classList.add('parvus-trigger')
el.addEventListener('click', triggerParvus)
Expand Down Expand Up @@ -191,8 +194,9 @@ export default function Parvus (userOptions) {
GROUPS[EL_GROUP].triggerElements.splice(EL_INDEX, 1)
GROUPS[EL_GROUP].sliderElements.splice(EL_INDEX, 1)

// Remove lightbox indicator icon
removeZoomIndicator(el)
if (config.zoomIndicator) {
removeZoomIndicator(el)
}

if (isOpen() && EL_GROUP === activeGroup) {
updateAttributes()
Expand Down

0 comments on commit e65d5c7

Please sign in to comment.