cone's image carousel (edited for scp-jp-storage)
{$caption}
Based on
Croquembouche's Image Carousel (Deprecated)
|images=file:3427263-1-hy7w@表紙A
<html ng-app="carousel" ng-controller="CarouselController"> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.2/angular.min.js"></script> <script src="http://topia.wikidot.com/local--code/carousel4scp-jp-storage/2"></script> <link href="http://d3g0gp89917ko0.cloudfront.net/v--edac79f846ba/common--theme/base/css/style.css" rel="stylesheet"> <link href="http://www.scp-wiki.net/component:theme/code/1" rel="stylesheet"> <link href="http://topia.wikidot.com/local--code/cqb%3Acarousel/4" rel="stylesheet"> </head> <body> <div class="wrapper" id="background"> <div class="carousel"> <div class="horsie" ng-repeat="image in images track by $index" ng-class="[index > $index ? 'past' : null, index === $index ? 'present' : null, index < $index ? 'future' : null]"> <img ng-src="{{image}}"> </div> </div> <div class="arrow decrementor" ng-class="index === 0 ? 'inactive' : 'active'" ng-click="increment(-1)"> <div class="image"></div> </div> <div class="arrow incrementor" ng-class="index === images.length-1 ? 'inactive' : 'active'" ng-click="increment(1)"> <div class="image"></div> </div> <div class="bubble-holder" ng-class="[options === 'yes' ? null : 'invisible']"> <div class="bubble" ng-repeat="image in images track by $index" ng-class="[index === $index ? 'present' : null]" ng-click="selectImage($index)"> </div> </div> <div class="control play" ng-click="control('play')" ng-class="[state === 'play' ? 'active' : null, options === 'yes' ? null : 'invisible']"></div> <div class="control pause" ng-click="control('pause')" ng-class="[state === 'pause' ? 'active' : null, options === 'yes' ? null : 'invisible']"></div> </div> </body> </html>
function getQueryVariable(variable) { var query = document.location.href.match(/\?.*$/g)[0].substring(1); var vars = query.split("&"); for(var i = 0; i < vars.length; i++) { // > var pair = vars[i].split("="); if(pair[0] === variable) return pair[1]; } return false; } (function(){ var carousel = angular .module('carousel',[]) .controller('CarouselController',CarouselController); CarouselController.$inject = ['$scope','$timeout']; function CarouselController($scope,$timeout){ $scope.images = getQueryVariable("images").split(",").map(v=>v.split('@')); for(var i = 0; i < $scope.images.length; i++) { // > $scope.images[i] = `http://scp-jp-storage.wdfiles.com/local--files/${$scope.images[i][0]}/${$scope.images[i][1]}`; } // $scope.images is an array of image URLs $scope.index = 0; $scope.increment = function(amount) { if(amount > 0 && $scope.index < $scope.images.length-1) { $scope.index += amount; } if(amount < 0 && $scope.index > 0) { $scope.index += amount; } $scope.state = "pause"; } var interval = getQueryVariable("interval") || 0; if(interval === "{$interval}") interval = 0; $scope.state = "play"; if(interval === 0) $scope.state = "pause"; function oscillate() { $timeout(function() { if(!mouseover && $scope.state === "play") { if($scope.index < $scope.images.length-1) { $scope.index++; } else { $scope.index = 0; } } if($scope.state === "play") { oscillate(); } }, interval*1000, true); } var mouseover = false; document.documentElement.onmouseover = function () { mouseover = true; } document.documentElement.onmouseout = function () { mouseover = false; } if($scope.state === "play") { oscillate(); } document.getElementById('background').style.background = getQueryVariable("background"); $scope.selectImage = function(index) { $scope.index = index; $scope.state = "pause"; } $scope.control = function(direction) { switch(direction) { case "play": $scope.state = "play"; oscillate(); break; case "pause": $scope.state = "pause"; break; } } $scope.options = getQueryVariable("options"); if($scope.options === "{$options}") $scope.options = "yes"; } })();
page revision: 1, last edited: 04 Dec 2020 13:35






