From 8f48dd3e897eca25b8ea941f1eed3b30e0c9cb8b Mon Sep 17 00:00:00 2001 From: ewelina Date: Wed, 1 Feb 2017 18:17:33 +0000 Subject: [PATCH] Wrap js file into function related #8 --- slider.js | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/slider.js b/slider.js index 8367ada..ba4b8ae 100644 --- a/slider.js +++ b/slider.js @@ -1,18 +1,13 @@ -//lets populate reel numbers -var min = $(".slider__range").attr("min"); -var max = $(".slider__range").attr("max"); - -updateOutput($(".slider__range").val()); - -var horizontal; -function updateOutput(figure) { - //displaying the static output - $(".slider__banana").html(figure); - - //positioning .static-output and .reel - //horizontal positioning first - horizontal = figure/max*($(".eating__slider").width()-$(".slider__reel").width()) + 'px'; - - //applying the positions - $(".slider__banana, .slider__reel").css({left: horizontal}); -} +(function($){ + 'use strict'; + var min = $(".slider__range").attr("min"); + var max = $(".slider__range").attr("max"); + var horizontal; + + window.updateOutput = function (figure) { + $(".slider__banana").html(figure); + horizontal = figure/max*($(".eating__slider").width()-$(".slider__reel").width()) + 'px'; + $(".slider__banana, .slider__reel").css({left: horizontal}); + } + updateOutput($(".slider__range").val()); +})(jQuery);