There was a question about the correct approach to creating a plugin on js.
An example of work on Plunker , as well as github code.
The essence of the plugin:
- There are images on the page, when clicking on them, a modal window opens;
- In this modal window there is a Slider and Previews with these images, which we can scroll through, switch, etc .;
- in the slider we can transfer the parameters for displaying the number of previews and the ability to turn them off;
- on one page we can use the plugin several times.
Problem : when used two or more times, the plugin breaks down and displays only the last gallery.
(function() { let gallery_1 = new SkySlider('.first-gallery'); let gallery_2 = new SkySlider('#second-gallery', { showThumbnails: true, thumbnailsItemCount: 6, }); })();
thisworks, and not to try crutches with one local variable for all instances - Grundy_"global" for all sliders, so when creating a new slider, all old ones in_change tothisnew slider (all due to the closure) - ThisManSkySlider? - ThisMan