사용자:BANIP/플러그인/슬라이드: 두 판 사이의 차이
둘러보기로 이동
검색으로 이동
백괴게임>BANIP 잔글편집 요약 없음 |
잔글 (판 6개를 가져왔습니다: 백괴슬라이드/플러그인 테스트) |
||
(사용자 4명의 중간 판 4개는 보이지 않습니다) | |||
6번째 줄: | 6번째 줄: | ||
{{#vardefine:name|Slideable}} | {{#vardefine:name|Slideable}} | ||
{{#vardefine:creat|BANIP}} | {{#vardefine:creat|BANIP}} | ||
{{#vardefine:version|1.0. | {{#vardefine:version|1.0.21}} | ||
{{#vardefine:descript|슬라이드 플러그인 라이브러리}} | {{#vardefine:descript|슬라이드 플러그인 라이브러리}} | ||
{{#vardefine:local|true}} | {{#vardefine:local|true}} | ||
34번째 줄: | 34번째 줄: | ||
$target.find(".bottom.on").css("background","url('https://upload.wikimedia.org/wikipedia/commons/f/f2/Arrow_bottom_svg.svg') no-repeat center"); | $target.find(".bottom.on").css("background","url('https://upload.wikimedia.org/wikipedia/commons/f/f2/Arrow_bottom_svg.svg') no-repeat center"); | ||
$target.find(".left.on").css("background","url('https://upload.wikimedia.org/wikipedia/commons/4/40/Arrowleft_svg.svg') no-repeat center"); | $target.find(".left.on").css("background","url('https://upload.wikimedia.org/wikipedia/commons/4/40/Arrowleft_svg.svg') no-repeat center"); | ||
$target.find(".right.on").css("background","url('https://upload.wikimedia.org/wikipedia/commons/ | $target.find(".right.on").css("background","url('https://upload.wikimedia.org/wikipedia/commons/e/ec/Arrow2right.svg') no-repeat center"); | ||
} | } | ||
114번째 줄: | 114번째 줄: | ||
util.moveObject($(this), moveInterval); | util.moveObject($(this), moveInterval); | ||
var hideDirection = util.isHideable($(this), moveInterval, moveLimit); | var hideDirection = util.isHideable($(this), moveInterval, moveLimit); | ||
if (hideDirection) util.hide(hideDirection, $(this)); | if (hideDirection) util.hide(hideDirection, $(this)); | ||
} | } | ||
144번째 줄: | 143번째 줄: | ||
util.moveObject($(this), moveInterval); | util.moveObject($(this), moveInterval); | ||
var hideDirection = util.isHideable($(this), moveInterval, moveLimit); | var hideDirection = util.isHideable($(this), moveInterval, moveLimit); | ||
if (hideDirection) util.hide(hideDirection, $(this)); | if (hideDirection) util.hide(hideDirection, $(this)); | ||
} | } | ||
199번째 줄: | 197번째 줄: | ||
var slideableItem = slideableArray[start]; | var slideableItem = slideableArray[start]; | ||
switch (typeof slideableItem) { | switch (typeof slideableItem) { | ||
case "function": | case "function": | ||
223번째 줄: | 220번째 줄: | ||
!!!!!!!!!!!!!!!! 플러그인 정보 입력 구간 끝 아래는 만지지 마시오!!!!!!!!!!!!!!!!! | !!!!!!!!!!!!!!!! 플러그인 정보 입력 구간 끝 아래는 만지지 마시오!!!!!!!!!!!!!!!!! | ||
</div>{{#switch: {{{1|화면}}} | </div>{{#switch: {{{1|화면}}} | ||
|dump = | |dump = | ||
|화면 = | |화면 = {{플러그인/preset/각주}} | ||
<p<includeonly></includeonly>re class="script" data-name="{{#var:name}}" | <p<includeonly></includeonly>re class="script" data-name="{{#var:name}}" | ||
data-create="{{#var:creat}}" | data-create="{{#var:creat}}" |
2024년 11월 14일 (목) 02:11 기준 최신판
이 플러그인에 대한 설명문서는 사용자:BANIP/플러그인/슬라이드/설명문서에서 만들 수 있습니다.
// 이부부분에 코드 입력 // //모든 키 순회 function forEach(object, callback) { for (var key in object) { var variable = object[key]; callback(variable, key); } } function create(directionData) { function initClassName($target, data) { forEach(data, function(value, direction) { $target.find("." + direction).addClass("on"); }) } function initDOM($target, data) { $target[0].data = data; $target.find(".center").html(data.center); $target.find(".top.on").css("background","url('https://upload.wikimedia.org/wikipedia/commons/8/85/Arrow_top_svg.svg') no-repeat center"); $target.find(".bottom.on").css("background","url('https://upload.wikimedia.org/wikipedia/commons/f/f2/Arrow_bottom_svg.svg') no-repeat center"); $target.find(".left.on").css("background","url('https://upload.wikimedia.org/wikipedia/commons/4/40/Arrowleft_svg.svg') no-repeat center"); $target.find(".right.on").css("background","url('https://upload.wikimedia.org/wikipedia/commons/e/ec/Arrow2right.svg') no-repeat center"); } var slideUtil = { moveObject: function($this, axis) { var x = axis[0], y = axis[1]; var data = $this[0].data; if (!data.right && x > 0) x = 0; if (!data.left && x < 0) x = 0; if (!data.top && y < 0) y = 0; if (!data.bottom && y > 0) y = 0; $this.css("transform", "translate(" + x + "px," + y + "px)"); }, isHideable: function($this, axis, limit) { var x = axis[0], y = axis[1]; var data = $this[0].data; if (data.right && x > limit) return "right"; if (data.left && x < limit * -1) return "left"; if (data.bottom && y > limit) return "bottom"; if (data.top && y < limit * -1) return "top"; }, hide: function(direction, $this) { function getCss(direction) { var css = { opacity: 0.01 }; var interval = 50; switch (direction) { case "left": css.left = -1 * interval + "vw"; break; case "right": css.left = interval + "vw"; break; case "bottom": css.top = interval + "vh"; break; case "top": css.top = -1 * interval + "vh"; break; } return css; } var self = $this[0]; var data = self.data; if (self.isHide === true) { return; } self.isHide = true; $this.animate(getCss(direction), { duration: 300, easing: "swing", start: data[direction], complete: function() { $this.remove(); } }); } } function setEvent($target, data) { var util = slideUtil; var moveLimit = 50; $(".slideable").mousedown(function(e) { this.isMouseDown = true; this.startAxis = [e.clientX, e.clientY]; }) $(".slideable").mousemove(function(e) { if (this.isMouseDown) { event.preventDefault() var axis = [e.clientX, e.clientY]; var startAxis = this.startAxis; var moveInterval = [axis[0] - startAxis[0], axis[1] - startAxis[1]] util.moveObject($(this), moveInterval); var hideDirection = util.isHideable($(this), moveInterval, moveLimit); if (hideDirection) util.hide(hideDirection, $(this)); } }) $(".slideable").mouseup(function(e) { this.isMouseDown = false; }) function getTouchEvent(e) { return e.originalEvent.touches[0] } $(".slideable").on("touchstart", function(e) { var touch = getTouchEvent(e); this.isMouseDown = true; this.startAxis = [touch.clientX, touch.clientY]; }) $(".slideable").on("touchmove", function(e) { event.preventDefault() if (this.isMouseDown) { event.preventDefault() var touch = getTouchEvent(e); var axis = [touch.clientX, touch.clientY]; var startAxis = this.startAxis; var moveInterval = [axis[0] - startAxis[0], axis[1] - startAxis[1]] util.moveObject($(this), moveInterval); var hideDirection = util.isHideable($(this), moveInterval, moveLimit); if (hideDirection) util.hide(hideDirection, $(this)); } }) $(".slideable").on("touchend", function(e) { this.isMouseDown = false; }) } //슬라이드아이템의 방향키로 숫자 혹은 문자로 지정된 경우 //함수로 변환 function setExecutable(target, item){ forEach(item,function(value,direction){ new Promise(function(resolve, reject){ if(direction === "center"){ switch( typeof value ){ case "function": resolve( value.bind(target)() ); break; } } else { switch( typeof value ){ case "string": case "number": resolve(function(){ execute(value); }.bind(target)); break; } } }).then(function(result){ item[direction] = result; }) }) } var $target = $(".slideable.cloneable").clone().removeClass("cloneable"); $("body").prepend($target); setExecutable($target[0], directionData); initClassName($target, directionData); initDOM($target, directionData); setEvent($target, directionData); } // create는 다른 함수들에 의존하지 않음 // var game; function execute(number, argument) { dispose(game, number, argument); } function dispose(slideableArray, start, argument) { game = slideableArray; var slideableItem = slideableArray[start]; switch (typeof slideableItem) { case "function": slideableItem(argument); break; case "object": create(slideableItem); break; } } //모바일 전체화면으로 수정 var setFullScreen = (function(){ //window.scrollTo(0,1); })(); return { create: create, execute: execute, dispose: dispose }