๋๋๊ทธ ๊ฐ๋ฅํ ๋
ธ๋๋ก ๋ค์ด์ด๊ทธ๋จ์ ํฌ/์คํ๊ธฐ ์ํด jquery.draggable๊ณผ ํจ๊ป ์ด ๋ฉ์ง ํ๋ฌ๊ทธ์ธ์ ์ฌ์ฉํ์ต๋๋ค.
๊ทธ๋ฌ๋ ์ต์ Chrome ์
๋ฐ์ดํธ ํ์ ๋
ธ๋๋ฅผ ๋ ์ ์๊ฒ ๋ฉ๋๋ค.
์ฝ๊ฐ์ ์กฐ์ฌ์ ๋ฐ๋ฅด๋ฉด Chrome์ ํฌ์ธํฐ ๋ค์ด ์ด๋ฒคํธ๋ก ๋ฌด์ธ๊ฐ๋ฅผ ๋ณ๊ฒฝํ์ต๋๋ค.
๊ทธ๋์ ์ด์ panzoom ํ๋ฌ๊ทธ์ธ์ mousedown ์ด๋ฒคํธ๊ฐ ๋ฐ์ํ๊ธฐ ์ ์ ์์ ๋
ธ๋์ pointerdown ์ด๋ฒคํธ์ ์๋ตํฉ๋๋ค.
Panzoom์ pointerdown ์ด๋ฒคํธ๋ฅผ ์ต์ ํ๊ณ ์ด๋ค ์ด์ ๋ก ๊ทธ ์ดํ์ mousedown ์ด๋ฒคํธ๊ฐ ์์ผ๋ฏ๋ก ๋๋๊ทธ๊ฐ ์์๋์ง ์์ต๋๋ค.
jquery.panzoom.js v3.2.2
jQuery 3.1.0 ๋๋ v1.11.3
jqueryui 1.12.0 ๋๋ 1.10.3
ํฌ๋กฌ 55.0.2883.75(64๋นํธ) ์ฐ๋ถํฌ 16.04
์ฌ๊ธฐ ๋ฐ๋ชจ๊ฐ ์์ต๋๋ค
http://codepen.io/yurigor/pen/yVjeGB
์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด 'ignoreChildrensEvents' ์ต์
์ ์ถ๊ฐํ์ต๋๋ค.
์ด ๋ณ๊ฒฝ ์ฌํญ์ผ๋ก pull ์์ฒญ์ ํด์ผ ํ๋์ง ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค.
ํฌ๋กฌ v55 ๊ฐ์ ๋ฌธ์ ๊ฐ ์์ต๋๋ค. ๋๋๊ทธ ๊ฐ๋ฅํ ์ฐฝ์ด ์๋๋ฐ ์ด๋ฆฐ์ด๋ฅผ ์ํ ๋ง์ฐ์ค๋ค์ด ์ด๋ฒคํธ๋ฅผ ๋ฐ๊ณ ์ถ์ต๋๋ค. ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด ๋ฌด์์ ํ์ จ์ต๋๊น? ๋ณ๊ฒฝ ์ฌํญ์ด ์๋ ์ง์ ์ด ์์ต๋๊น? ์ง๊ธ์ ๋งํ ์์ต๋๋ค.
๋น์ ์ ์ง์ ์ ์ฐพ์๊ณ ๊ทธ๊ฒ์ ๋ด ๋ฌธ์ ๋ฅผ ์์ฃผ ํ๋ฅญํ๊ฒ ํด๊ฒฐํฉ๋๋ค. YuriGor ๊ฐ์ฌํฉ๋๋ค ์ด๊ฒ์ ํ๋ฅญํฉ๋๋ค
๋์ ์ค ์์์ด์ ๊ธฐ๋ป!
ํ์ํ์ ๋ถ๋ค์ ์ํด ๋ค์ ๋งํฌ๋ฅผ ์ฐธ์กฐํ์ธ์.
https://github.com/YuriGor/jquery.panzoom/tree/ignoreChildrensEvents/dist
@timmywil , ๋ด ๋ณ๊ฒฝ ์ฌํญ์ ๋ณํฉํ๋ ค๋ฉด grunt๋ฅผ ๋์์ฃผ์ธ์.
๋๋ livereload๋ฅผ ์์ํ๋ค
grunt watch:dev
ํ์ง๋ง ์๋ํ์ง ์์ต๋๋ค.
http://localhost :35711/์์
{"tinylr":"Welcome","version":"0.2.1"}
๊ทธ๋ฆฌ๊ณ ์
http://localhost :35711/test/index.html
๋๋
http://localhost :35711/demo/index.html
๋๋ ๊ฐ์ง๊ณ ์๋ค
{"error":"not_found","reason":"no such route"}
์ ๋ง ๊ฐ์ฌํฉ๋๋ค. ์ด ์์ ์ผ๋ก๋ ์ถฉ๋ถํ์ง ์์์ง๋ง ๋ด ๊ฒฝ์ฐ์ ์์ ํ๊ธฐ ์ํด ๋ช ๊ฐ์ง๋ฅผ ์ถ๊ฐํ์ต๋๋ค. (๋๋ ์ค์ฒฉ๋ ์์์ด ์ฌ๋ฌ ๊ฐ ์๋๋ฐ ๊ทธ ์ค ์ผ๋ถ๋ ๋ฌด์ํด์ผ ํ๊ณ ๋๋จธ์ง๋ ๋ฌด์ํด์๋ ์ ๋ฉ๋๋ค.)
@timmywil ์ด ์ต์ ์ผ๋ก ์ ๋ฒ์ ์ ์ถ์ํ ์ ์๋์?
ํธ์ง : ์ค์ ๋ก romi45์ ๋์ผํ ๋ฌธ์ ๊ฐ ์์ต๋๋ค. ๐
ํธ์ง 2: ๋ค์๊ณผ ๊ฐ์ด ๋ฌด์ํ ์์๋ฅผ ๋์ดํ๋ ์ต์ ์ด ์ ์ฉํฉ๋๋ค.
ignoreChildEventsFrom: [".things-to-ignore1", ".things-to-ignore2"]
ํธ์ง 3: FAQ "๋งํฌ๊ฐ Panzoom ์์ ๋ด์ ์๋ ๊ฒฝ์ฐ ์ด๋ป๊ฒ ์๋ํ๊ฒ ํฉ๋๊น?"์์ ์๋ฃจ์ ์ ์ฐพ์ ๊ฒ ๊ฐ์ต๋๋ค.
๋ด๊ฐ ํ๋ ์ผ์ 969ํ์์ preventDefault๋ฅผ ์ฃผ์ ์ฒ๋ฆฌํ๋ ๊ฒ์ ๋๋ค. preventDefault๋ ์ด๋ฒคํธ๊ฐ ์์์ ๋๋ฌํ์ง ๋ชปํ๋๋ก ์ฐจ๋จํฉ๋๋ค.
@akhnaz ,
๋ด ์ดํด์์ preventDefault
๋ ์์(์์ ๋๋ panzoom ์์ ์์ฒด)์ ๊ด๋ จ๋ ๊ธฐ๋ณธ ์์
์ ๋ฐฉ์งํ๊ณ stopPropagation
๋ ์ด๋ฒคํธ๊ฐ ์์ ์์๋ก ๋ฒ๋ธ๋ง๋๋ ๊ฒ์ ์ค์งํฉ๋๋ค.
FAQ์๋ ๊ฐ๋จํ๊ณ ์ฐ์ํ ์๋ฃจ์ ์ด ์์ต๋๋ค.
$('.panzoom a').on('mousedown touchstart', function( e ) {
e.stopImmediatePropagation();
});
์ด๋ฅผ ์ํด์๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์์ฒด๋ฅผ ๋ณ๊ฒฝํ ํ์๊ฐ ์์ต๋๋ค.
์๋ ํ์ธ์ @glen-84
์, preventDefault๋ ๊ธฐ๋ณธ ์์ ์ ๋ฐฉ์งํฉ๋๋ค. ๊ทธ๋ฌ๋ pointerDown์ด ์ ๋ฌ๋๊ณ ์์ ๋ ๋ ์์์ mouseDown๋ ๋ฐฉ์งํฉ๋๋ค.
ํฌ๋กฌ 55์์๋ ์ด์ pointerDown์ด ๋์คํจ์น๋๊ณ microsoft edge๋ ์ด๋ฏธ ์ฒ์๋ถํฐ pointerDown์ ๊ตฌํํ๊ณ ์์ต๋๋ค.
์ ๊ฒฝ์ฐ panzoom์ pointerDown์ ๋ฃ๊ณ ์์ด๋ค์ mouseDown์ ๋ฃ์ต๋๋ค.
์ฌ๊ธฐ์ ๋ด jsbin์ด ์์ต๋๋ค.
@akhnaz ,
์์ด์๊ฒ pointerdown
๋ฅผ ๋ฃ๊ณ ์ฆ๊ฐ์ ์ธ ์ ํ๋ฅผ ๋ฉ์ถ ์ ์์ต๋๋ค ...
https://jsbin.com/sicapuledo/edit?html,js ,์ฝ์,์ถ๋ ฅ
์๋ ํ์ธ์,
๋๋ ๋น์ ์ ๊ธฐ๋ฅ์ ์ฝ๊ฐ ๊ฐ์ ํ์ต๋๋ค. ๊ฐ๋ฅํ ํด๋์ค ๋ฐฐ์ด์ ๋ํ ์ต์ ์ ์ฌ์ ์ํฉ๋๋ค. ๋ชฉํ๋ ์์์๊ฒ ๋์ด๋ ํด๋์ค ์ค ํ๋๊ฐ ์๋ ๊ฒฝ์ฐ์๋ง ์ด๋ฒคํธ๋ฅผ ๋ฌด์ํ๋ ๊ฒ์ ๋๋ค. ๋ฌผ๋ก ๊ฐ์ true๋ก ์ค์ ํ๋ฉด ๊ตฌํํ ๋๋ก ์๋ํฉ๋๋ค.
์ ๋๋ก ํฌํฌํ๊ณ ํ ๋ฆฌํ์คํธ๋ฅผ ํ ์๊ฐ์ด ์์ต๋๋ค. ์์ ๊ฐ์ ์ฌํญ์ ํฌํจํ๊ณ ๊ธฐ๋ณธ ์ ์ฅ์๋ก ๊ฐ์ ธ์ค๊ธฐ๋ฅผ ์์ฒญํ์ญ์์ค.
๋ค์์ ํฌํฌ ๋ผ์ธ 959์์ ์ ๋ฐ์ดํธ๋ ์ฝ๋์ ๋๋ค.
if (!options.disablePan || !options.disableZoom) {
events[ str_start ] = function(e) {
if(options.ignoreChildrensEvents) {
if($.isArray(options.ignoreChildrensEvents)) {
if(options.ignoreChildrensEvents.find(function(c){return $(e.target).hasClass(c);})) {
return;
}
}
else if(e.target !== this){
return;
}
}
var touches;
/* rest of code */
ignoreChildrensEvents ์ต์ ์ true, false ๋๋ ['child-class1', 'child-class2']๋ก ์ ์ํ ์ ์์ต๋๋ค.
๋ฌธ์ ์ธ์ฌ
ignoreChildrensEvents๊ฐ ํฌํจ๋ ์ต์ ๋ฒ์ ์ ์ถ์ํ์ญ์์ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
๋์ ์ค ์์์ด์ ๊ธฐ๋ป!
ํ์ํ์ ๋ถ๋ค์ ์ํด ๋ค์ ๋งํฌ๋ฅผ ์ฐธ์กฐํ์ธ์.
https://github.com/YuriGor/jquery.panzoom/tree/ignoreChildrensEvents/dist
@timmywil , ๋ด ๋ณ๊ฒฝ ์ฌํญ์ ๋ณํฉํ๋ ค๋ฉด grunt๋ฅผ ๋์์ฃผ์ธ์.
๋๋ livereload๋ฅผ ์์ํ๋ค
grunt watch:dev
ํ์ง๋ง ์๋ํ์ง ์์ต๋๋ค.
http://localhost :35711/์์
{"tinylr":"Welcome","version":"0.2.1"}
๊ทธ๋ฆฌ๊ณ ์
http://localhost :35711/test/index.html
๋๋
http://localhost :35711/demo/index.html
๋๋ ๊ฐ์ง๊ณ ์๋ค
{"error":"not_found","reason":"no such route"}