How can I minimize the code lines using (for each)
swiper one
var swiperCurrent;
var swiper = new Swiper('.swiper-container-1',
init: false,
pagination: '.swiper-pagination-1',
nextButton: '.swiper-button-next-1',
prevButton: '.swiper-button-prev-1',
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10
,
runCallbacksOnInit:true
);
function showSliderContent2(idx)
$('._ooredoo_banner_content_1> div').hide(0);
$('._ooredoo_banner_content_1> div:eq('+ idx +')').fadeIn(200)
swiper.on('init', function (el)
showSliderContent(el.activeIndex);
);
swiper.on('transitionEnd', function (el)
if(swiperCurrent !== el.activeIndex)
showSliderContent(el.activeIndex);
swiperCurrent = el.activeIndex;
);
swiper.init();
swiper two
var swiperCurrent2;
var swiper = new Swiper('.swiper-container-2,
init: false,
pagination: '.swiper-pagination-2',
nextButton: '.swiper-button-next-2',
prevButton: '.swiper-button-prev-2',
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10
,
runCallbacksOnInit:true
);
function showSliderContent2(idx)
$('._ooredoo_banner_content_2> div').hide(0);
$('._ooredoo_banner_content_2> div:eq('+ idx +')').fadeIn(200)
swiper.on('init', function (el)
showSliderContent2(el.activeIndex);
);
swiper.on('transitionEnd', function (el)
if(swiperCurrent2 !== el.activeIndex)
showSliderContent2(el.activeIndex);
swiperCurrent2 = el.activeIndex;
);
swiper.init();
swiper three
var swiperCurrent3;
var swiper = new Swiper('.swiper-container-3’,
init: false,
pagination: '.swiper-pagination-3',
nextButton: '.swiper-button-next-3',
prevButton: '.swiper-button-prev-3',
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10
,
runCallbacksOnInit:true
);
function showSliderContent3(idx)
$('._ooredoo_banner_content_3> div').hide(0);
$('._ooredoo_banner_content_3> div:eq('+ idx +')').fadeIn(200)
swiper.on('init', function (el)
showSliderContent3(el.activeIndex);
);
swiper.on('transitionEnd', function (el)
if(swiperCurrent3 !== el.activeIndex)
showSliderContent3(el.activeIndex);
swiperCurrent3 = el.activeIndex;
);
swiper.init();
javascript jquery foreach swiper
add a comment |
swiper one
var swiperCurrent;
var swiper = new Swiper('.swiper-container-1',
init: false,
pagination: '.swiper-pagination-1',
nextButton: '.swiper-button-next-1',
prevButton: '.swiper-button-prev-1',
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10
,
runCallbacksOnInit:true
);
function showSliderContent2(idx)
$('._ooredoo_banner_content_1> div').hide(0);
$('._ooredoo_banner_content_1> div:eq('+ idx +')').fadeIn(200)
swiper.on('init', function (el)
showSliderContent(el.activeIndex);
);
swiper.on('transitionEnd', function (el)
if(swiperCurrent !== el.activeIndex)
showSliderContent(el.activeIndex);
swiperCurrent = el.activeIndex;
);
swiper.init();
swiper two
var swiperCurrent2;
var swiper = new Swiper('.swiper-container-2,
init: false,
pagination: '.swiper-pagination-2',
nextButton: '.swiper-button-next-2',
prevButton: '.swiper-button-prev-2',
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10
,
runCallbacksOnInit:true
);
function showSliderContent2(idx)
$('._ooredoo_banner_content_2> div').hide(0);
$('._ooredoo_banner_content_2> div:eq('+ idx +')').fadeIn(200)
swiper.on('init', function (el)
showSliderContent2(el.activeIndex);
);
swiper.on('transitionEnd', function (el)
if(swiperCurrent2 !== el.activeIndex)
showSliderContent2(el.activeIndex);
swiperCurrent2 = el.activeIndex;
);
swiper.init();
swiper three
var swiperCurrent3;
var swiper = new Swiper('.swiper-container-3’,
init: false,
pagination: '.swiper-pagination-3',
nextButton: '.swiper-button-next-3',
prevButton: '.swiper-button-prev-3',
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10
,
runCallbacksOnInit:true
);
function showSliderContent3(idx)
$('._ooredoo_banner_content_3> div').hide(0);
$('._ooredoo_banner_content_3> div:eq('+ idx +')').fadeIn(200)
swiper.on('init', function (el)
showSliderContent3(el.activeIndex);
);
swiper.on('transitionEnd', function (el)
if(swiperCurrent3 !== el.activeIndex)
showSliderContent3(el.activeIndex);
swiperCurrent3 = el.activeIndex;
);
swiper.init();
javascript jquery foreach swiper
1
what is your question exactly?
– jtate
Nov 12 '18 at 20:11
It seems like what you want to know is how to create these three swipers (and maybe more) without having to duplicate all that code? Remember that in JavaScript you can return functions as values from other functions (and pass them around). So I'd look at the similarities between the three (and there are many) and then use the principals of Closures and function creation to make a utility method that took in arguments for any dissimilar value.
– lemieuxster
Nov 12 '18 at 20:43
add a comment |
swiper one
var swiperCurrent;
var swiper = new Swiper('.swiper-container-1',
init: false,
pagination: '.swiper-pagination-1',
nextButton: '.swiper-button-next-1',
prevButton: '.swiper-button-prev-1',
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10
,
runCallbacksOnInit:true
);
function showSliderContent2(idx)
$('._ooredoo_banner_content_1> div').hide(0);
$('._ooredoo_banner_content_1> div:eq('+ idx +')').fadeIn(200)
swiper.on('init', function (el)
showSliderContent(el.activeIndex);
);
swiper.on('transitionEnd', function (el)
if(swiperCurrent !== el.activeIndex)
showSliderContent(el.activeIndex);
swiperCurrent = el.activeIndex;
);
swiper.init();
swiper two
var swiperCurrent2;
var swiper = new Swiper('.swiper-container-2,
init: false,
pagination: '.swiper-pagination-2',
nextButton: '.swiper-button-next-2',
prevButton: '.swiper-button-prev-2',
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10
,
runCallbacksOnInit:true
);
function showSliderContent2(idx)
$('._ooredoo_banner_content_2> div').hide(0);
$('._ooredoo_banner_content_2> div:eq('+ idx +')').fadeIn(200)
swiper.on('init', function (el)
showSliderContent2(el.activeIndex);
);
swiper.on('transitionEnd', function (el)
if(swiperCurrent2 !== el.activeIndex)
showSliderContent2(el.activeIndex);
swiperCurrent2 = el.activeIndex;
);
swiper.init();
swiper three
var swiperCurrent3;
var swiper = new Swiper('.swiper-container-3’,
init: false,
pagination: '.swiper-pagination-3',
nextButton: '.swiper-button-next-3',
prevButton: '.swiper-button-prev-3',
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10
,
runCallbacksOnInit:true
);
function showSliderContent3(idx)
$('._ooredoo_banner_content_3> div').hide(0);
$('._ooredoo_banner_content_3> div:eq('+ idx +')').fadeIn(200)
swiper.on('init', function (el)
showSliderContent3(el.activeIndex);
);
swiper.on('transitionEnd', function (el)
if(swiperCurrent3 !== el.activeIndex)
showSliderContent3(el.activeIndex);
swiperCurrent3 = el.activeIndex;
);
swiper.init();
javascript jquery foreach swiper
swiper one
var swiperCurrent;
var swiper = new Swiper('.swiper-container-1',
init: false,
pagination: '.swiper-pagination-1',
nextButton: '.swiper-button-next-1',
prevButton: '.swiper-button-prev-1',
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10
,
runCallbacksOnInit:true
);
function showSliderContent2(idx)
$('._ooredoo_banner_content_1> div').hide(0);
$('._ooredoo_banner_content_1> div:eq('+ idx +')').fadeIn(200)
swiper.on('init', function (el)
showSliderContent(el.activeIndex);
);
swiper.on('transitionEnd', function (el)
if(swiperCurrent !== el.activeIndex)
showSliderContent(el.activeIndex);
swiperCurrent = el.activeIndex;
);
swiper.init();
swiper two
var swiperCurrent2;
var swiper = new Swiper('.swiper-container-2,
init: false,
pagination: '.swiper-pagination-2',
nextButton: '.swiper-button-next-2',
prevButton: '.swiper-button-prev-2',
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10
,
runCallbacksOnInit:true
);
function showSliderContent2(idx)
$('._ooredoo_banner_content_2> div').hide(0);
$('._ooredoo_banner_content_2> div:eq('+ idx +')').fadeIn(200)
swiper.on('init', function (el)
showSliderContent2(el.activeIndex);
);
swiper.on('transitionEnd', function (el)
if(swiperCurrent2 !== el.activeIndex)
showSliderContent2(el.activeIndex);
swiperCurrent2 = el.activeIndex;
);
swiper.init();
swiper three
var swiperCurrent3;
var swiper = new Swiper('.swiper-container-3’,
init: false,
pagination: '.swiper-pagination-3',
nextButton: '.swiper-button-next-3',
prevButton: '.swiper-button-prev-3',
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10
,
runCallbacksOnInit:true
);
function showSliderContent3(idx)
$('._ooredoo_banner_content_3> div').hide(0);
$('._ooredoo_banner_content_3> div:eq('+ idx +')').fadeIn(200)
swiper.on('init', function (el)
showSliderContent3(el.activeIndex);
);
swiper.on('transitionEnd', function (el)
if(swiperCurrent3 !== el.activeIndex)
showSliderContent3(el.activeIndex);
swiperCurrent3 = el.activeIndex;
);
swiper.init();
javascript jquery foreach swiper
javascript jquery foreach swiper
edited Nov 12 '18 at 20:32
Scott Sauyet
19.7k22653
19.7k22653
asked Nov 12 '18 at 20:07
user3083972
1
1
1
what is your question exactly?
– jtate
Nov 12 '18 at 20:11
It seems like what you want to know is how to create these three swipers (and maybe more) without having to duplicate all that code? Remember that in JavaScript you can return functions as values from other functions (and pass them around). So I'd look at the similarities between the three (and there are many) and then use the principals of Closures and function creation to make a utility method that took in arguments for any dissimilar value.
– lemieuxster
Nov 12 '18 at 20:43
add a comment |
1
what is your question exactly?
– jtate
Nov 12 '18 at 20:11
It seems like what you want to know is how to create these three swipers (and maybe more) without having to duplicate all that code? Remember that in JavaScript you can return functions as values from other functions (and pass them around). So I'd look at the similarities between the three (and there are many) and then use the principals of Closures and function creation to make a utility method that took in arguments for any dissimilar value.
– lemieuxster
Nov 12 '18 at 20:43
1
1
what is your question exactly?
– jtate
Nov 12 '18 at 20:11
what is your question exactly?
– jtate
Nov 12 '18 at 20:11
It seems like what you want to know is how to create these three swipers (and maybe more) without having to duplicate all that code? Remember that in JavaScript you can return functions as values from other functions (and pass them around). So I'd look at the similarities between the three (and there are many) and then use the principals of Closures and function creation to make a utility method that took in arguments for any dissimilar value.
– lemieuxster
Nov 12 '18 at 20:43
It seems like what you want to know is how to create these three swipers (and maybe more) without having to duplicate all that code? Remember that in JavaScript you can return functions as values from other functions (and pass them around). So I'd look at the similarities between the three (and there are many) and then use the principals of Closures and function creation to make a utility method that took in arguments for any dissimilar value.
– lemieuxster
Nov 12 '18 at 20:43
add a comment |
1 Answer
1
active
oldest
votes
Something like the following (untested) code might help: All I did was to factor out the common code into a reusable function and use template strings to fill in the missing parts, then map
that function over the 1
, 2
, and 3
partial ids. This means we no longer need the 2
and 3
suffixes on some of the variables; they are only available inside the closures generated by the callback to map
.
There are likely bugs in this, either reusing something I shouldn't or the reverse: making something dynamic that doesn't have to be. In the first case, if you can continue to use the id
to distinguish it, great. If not, you might need one ore more additional variables, and the map
statement will have to get a little more complex.
const makeSwiper = (id) =>
var swiperCurrent;
var swiper = new Swiper('.swiper-container-2',
init: false,
pagination: `.swiper-pagination-$id`,
nextButton: `.swiper-button-next-$id`,
prevButton: `.swiper-button-prev-$id`,
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10
,
runCallbacksOnInit:true
);
function showSliderContent(idx)
$(`._ooredoo_banner_content_$id> div`).hide(0);
$(`._ooredoo_banner_content_$id> div:eq($idx)`).fadeIn(200)
swiper.on('init', function (el)
showSliderContent(el.activeIndex);
);
swiper.on('transitionEnd', function (el)
if(swiperCurrent !== el.activeIndex)
showSliderContent(el.activeIndex);
swiperCurrent = el.activeIndex;
);
return swiper
const swipers = [1, 2, 3].map(makeSwiper)
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53269351%2fhow-can-i-minimize-the-code-lines-using-for-each%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Something like the following (untested) code might help: All I did was to factor out the common code into a reusable function and use template strings to fill in the missing parts, then map
that function over the 1
, 2
, and 3
partial ids. This means we no longer need the 2
and 3
suffixes on some of the variables; they are only available inside the closures generated by the callback to map
.
There are likely bugs in this, either reusing something I shouldn't or the reverse: making something dynamic that doesn't have to be. In the first case, if you can continue to use the id
to distinguish it, great. If not, you might need one ore more additional variables, and the map
statement will have to get a little more complex.
const makeSwiper = (id) =>
var swiperCurrent;
var swiper = new Swiper('.swiper-container-2',
init: false,
pagination: `.swiper-pagination-$id`,
nextButton: `.swiper-button-next-$id`,
prevButton: `.swiper-button-prev-$id`,
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10
,
runCallbacksOnInit:true
);
function showSliderContent(idx)
$(`._ooredoo_banner_content_$id> div`).hide(0);
$(`._ooredoo_banner_content_$id> div:eq($idx)`).fadeIn(200)
swiper.on('init', function (el)
showSliderContent(el.activeIndex);
);
swiper.on('transitionEnd', function (el)
if(swiperCurrent !== el.activeIndex)
showSliderContent(el.activeIndex);
swiperCurrent = el.activeIndex;
);
return swiper
const swipers = [1, 2, 3].map(makeSwiper)
add a comment |
Something like the following (untested) code might help: All I did was to factor out the common code into a reusable function and use template strings to fill in the missing parts, then map
that function over the 1
, 2
, and 3
partial ids. This means we no longer need the 2
and 3
suffixes on some of the variables; they are only available inside the closures generated by the callback to map
.
There are likely bugs in this, either reusing something I shouldn't or the reverse: making something dynamic that doesn't have to be. In the first case, if you can continue to use the id
to distinguish it, great. If not, you might need one ore more additional variables, and the map
statement will have to get a little more complex.
const makeSwiper = (id) =>
var swiperCurrent;
var swiper = new Swiper('.swiper-container-2',
init: false,
pagination: `.swiper-pagination-$id`,
nextButton: `.swiper-button-next-$id`,
prevButton: `.swiper-button-prev-$id`,
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10
,
runCallbacksOnInit:true
);
function showSliderContent(idx)
$(`._ooredoo_banner_content_$id> div`).hide(0);
$(`._ooredoo_banner_content_$id> div:eq($idx)`).fadeIn(200)
swiper.on('init', function (el)
showSliderContent(el.activeIndex);
);
swiper.on('transitionEnd', function (el)
if(swiperCurrent !== el.activeIndex)
showSliderContent(el.activeIndex);
swiperCurrent = el.activeIndex;
);
return swiper
const swipers = [1, 2, 3].map(makeSwiper)
add a comment |
Something like the following (untested) code might help: All I did was to factor out the common code into a reusable function and use template strings to fill in the missing parts, then map
that function over the 1
, 2
, and 3
partial ids. This means we no longer need the 2
and 3
suffixes on some of the variables; they are only available inside the closures generated by the callback to map
.
There are likely bugs in this, either reusing something I shouldn't or the reverse: making something dynamic that doesn't have to be. In the first case, if you can continue to use the id
to distinguish it, great. If not, you might need one ore more additional variables, and the map
statement will have to get a little more complex.
const makeSwiper = (id) =>
var swiperCurrent;
var swiper = new Swiper('.swiper-container-2',
init: false,
pagination: `.swiper-pagination-$id`,
nextButton: `.swiper-button-next-$id`,
prevButton: `.swiper-button-prev-$id`,
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10
,
runCallbacksOnInit:true
);
function showSliderContent(idx)
$(`._ooredoo_banner_content_$id> div`).hide(0);
$(`._ooredoo_banner_content_$id> div:eq($idx)`).fadeIn(200)
swiper.on('init', function (el)
showSliderContent(el.activeIndex);
);
swiper.on('transitionEnd', function (el)
if(swiperCurrent !== el.activeIndex)
showSliderContent(el.activeIndex);
swiperCurrent = el.activeIndex;
);
return swiper
const swipers = [1, 2, 3].map(makeSwiper)
Something like the following (untested) code might help: All I did was to factor out the common code into a reusable function and use template strings to fill in the missing parts, then map
that function over the 1
, 2
, and 3
partial ids. This means we no longer need the 2
and 3
suffixes on some of the variables; they are only available inside the closures generated by the callback to map
.
There are likely bugs in this, either reusing something I shouldn't or the reverse: making something dynamic that doesn't have to be. In the first case, if you can continue to use the id
to distinguish it, great. If not, you might need one ore more additional variables, and the map
statement will have to get a little more complex.
const makeSwiper = (id) =>
var swiperCurrent;
var swiper = new Swiper('.swiper-container-2',
init: false,
pagination: `.swiper-pagination-$id`,
nextButton: `.swiper-button-next-$id`,
prevButton: `.swiper-button-prev-$id`,
slidesPerView: 3,
centeredSlides: true,
paginationClickable: true,
initialSlide: 2,
spaceBetween: 22,
breakpoints:
992:
slidesPerView: 1,
spaceBetween: 10
,
runCallbacksOnInit:true
);
function showSliderContent(idx)
$(`._ooredoo_banner_content_$id> div`).hide(0);
$(`._ooredoo_banner_content_$id> div:eq($idx)`).fadeIn(200)
swiper.on('init', function (el)
showSliderContent(el.activeIndex);
);
swiper.on('transitionEnd', function (el)
if(swiperCurrent !== el.activeIndex)
showSliderContent(el.activeIndex);
swiperCurrent = el.activeIndex;
);
return swiper
const swipers = [1, 2, 3].map(makeSwiper)
answered Nov 12 '18 at 20:44
Scott Sauyet
19.7k22653
19.7k22653
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53269351%2fhow-can-i-minimize-the-code-lines-using-for-each%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
what is your question exactly?
– jtate
Nov 12 '18 at 20:11
It seems like what you want to know is how to create these three swipers (and maybe more) without having to duplicate all that code? Remember that in JavaScript you can return functions as values from other functions (and pass them around). So I'd look at the similarities between the three (and there are many) and then use the principals of Closures and function creation to make a utility method that took in arguments for any dissimilar value.
– lemieuxster
Nov 12 '18 at 20:43