Skip to content

Commit

Permalink
Wrap js file into function
Browse files Browse the repository at this point in the history
related #8
  • Loading branch information
skibinska committed Feb 1, 2017
1 parent f799076 commit 8f48dd3
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions slider.js
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 8f48dd3

Please sign in to comment.