| 406 | var scrollsvg = function(delta){ |
| 407 | // 迴セ蝨ィ縺ョ繝薙Η繝シ繝懊ャ繧ッ繧ケ縺ョ迥カ諷九r蜿門セ� |
| 408 | var vb = svg.attr("viewBox"); |
| 409 | // 繧ケ繝壹�繧ケ縺ァ蛹コ蛻�j蜷�、縺ォ蛻�ァ」 |
| 410 | var spvb = vb.split(" "); |
| 411 | |
| 412 | // 繝薙Η繝シ繝懊ャ繧ッ繧ケ縺ョy縺ョ蛟、縺九i莉雁屓縺ョ繝帙う繝シ繝ォ繧、繝吶Φ繝医�蟾ョ蛻�r蠑輔¥ |
| 413 | var vby = (parseInt(spvb[1]) - parseInt(delta)); |
| 414 | |
| 415 | // 0繧貞牡縺」縺ヲ縺�◆繧�縺ォ |
| 416 | if(vby < 0){ |
| 417 | vby = 0; |
| 418 | // 繧ケ繧ッ繝ュ繝シ繝ォ荳企剞�医げ繝ゥ繝輔し繧、繧コ蠑輔¥陦ィ遉コ鬆伜沺繧オ繧、繧コ�峨r雜�∴縺ヲ縺�◆繧芽」懈ュ」 |
| 419 | }else if(vby > (graphheight - height)){ |
| 420 | vby = (graphheight - height); |
| 421 | // 陬懈ュ」縺励◆邨先棡0繧貞牡縺」縺ヲ縺�◆繧�縺ォ |
| 422 | if(vby < 0){ |
| 423 | vby = 0; |
| 424 | } |
| 425 | } |
| 426 | |
| 427 | // 縺薙%縺セ縺ァ縺ァ縺ァ縺阪◆y繧偵そ繝�ヨ縺励ン繝・繝シ繝懊ャ繧ッ繧ケ繧呈峩譁ー |
| 428 | svg.attr("viewBox", "0 " + vby + " " + width + " " + height); |
| 429 | } |
| 430 | |
422 | | .attr("viewBox", "0 0 " + width + " " + height) |
423 | | // 繧ケ繧ッ繝ュ繝シ繝ォ縺輔l縺溘i |
424 | | .on("mousewheel", function(){ |
425 | | // 迴セ蝨ィ縺ョ繝薙Η繝シ繝懊ャ繧ッ繧ケ縺ョ迥カ諷九r蜿門セ� |
426 | | var vb = svg.attr("viewBox"); |
427 | | // 繧ケ繝壹�繧ケ縺ァ蛹コ蛻�j蜷�、縺ォ蛻�ァ」 |
428 | | var spvb = vb.split(" "); |
429 | | |
430 | | // 繝薙Η繝シ繝懊ャ繧ッ繧ケ縺ョy縺ョ蛟、縺九i莉雁屓縺ョ繝帙う繝シ繝ォ繧、繝吶Φ繝医�蟾ョ蛻�r蠑輔¥ |
431 | | var vby = (parseInt(spvb[1]) - event.wheelDelta); |
432 | | |
433 | | // 0繧貞牡縺」縺ヲ縺�◆繧�縺ォ |
434 | | if(vby < 0){ |
435 | | vby = 0; |
436 | | // 繧ケ繧ッ繝ュ繝シ繝ォ荳企剞�医げ繝ゥ繝輔し繧、繧コ蠑輔¥陦ィ遉コ鬆伜沺繧オ繧、繧コ�峨r雜�∴縺ヲ縺�◆繧芽」懈ュ」 |
437 | | }else if(vby > (graphheight - height)){ |
438 | | vby = (graphheight - height); |
439 | | // 陬懈ュ」縺励◆邨先棡0繧貞牡縺」縺ヲ縺�◆繧�縺ォ |
440 | | if(vby < 0){ |
441 | | vby = 0; |
442 | | } |
443 | | } |
444 | | |
445 | | // 縺薙%縺セ縺ァ縺ァ縺ァ縺阪◆y繧偵そ繝�ヨ縺励ン繝・繝シ繝懊ャ繧ッ繧ケ繧呈峩譁ー |
446 | | svg.attr("viewBox", "0 " + vby + " " + width + " " + height); |
447 | | }); |
| 438 | .attr("viewBox", "0 0 " + width + " " + height); |
| 439 | |
| 440 | // SVG縺後せ繧ッ繝ュ繝シ繝ォ縺輔l縺滓凾縺ョ繧、繝吶Φ繝医r繝悶Λ繧ヲ繧カ縺ォ蠢懊§縺ヲ繧サ繝�ヨ |
| 441 | var mousewheelevent = 'onwheel' in document ? 'wheel' : 'onmousewheel' in document ? 'mousewheel' : 'DOMMouseScroll'; |
| 442 | $(".SBGraph svg").on(mousewheelevent,function(e){ |
| 443 | // 繝悶Λ繧ヲ繧カ縺ォ蠢懊§縺ヲ繧ケ繧ッ繝ュ繝シ繝ォ縺ョ蛟、繧貞叙蠕� |
| 444 | var delta = e.originalEvent.deltaY ? -(e.originalEvent.deltaY) : e.originalEvent.wheelDelta ? e.originalEvent.wheelDelta : -(e.originalEvent.detail); |
| 445 | // FireFox縺縺ィ繧ケ繧ッ繝ュ繝シ繝ォ騾溷コヲ縺碁撼蟶ク縺ォ驕�>蝣エ蜷医′縺ゅk縺ョ縺ァ陬懈ュ」 |
| 446 | if(delta < 0 && delta > -100){ |
| 447 | delta = -100; |
| 448 | }else if(0 < delta && delta < 100){ |
| 449 | delta = 100; |
| 450 | } |
| 451 | |
| 452 | // 繧ケ繧ッ繝ュ繝シ繝ォ縺ョ繝�ヵ繧ゥ繝ォ繝医�蜍穂ス懊→繝舌ヶ繝ェ繝ウ繧ー繧偵く繝」繝ウ繧サ繝ォ |
| 453 | e.preventDefault(); |
| 454 | e.stopPropagation(); |
| 455 | // 蛟、繧呈ク。縺励※繧ケ繧ッ繝ュ繝シ繝ォ |
| 456 | scrollsvg(delta); |
| 457 | }); |