PSD-Tutorials.de
Forum für Design, Fotografie & Bildbearbeitung
Tutkit
Agentur
Hilfe
Kontakt
Start
Forum
Aktuelles
Besonderer Inhalt
Foren durchsuchen
Tutorials
News
Anmelden
Kostenlos registrieren
Aktuelles
Suche
Suche
Nur Titel durchsuchen
Von:
Menü
Anmelden
Kostenlos registrieren
App installieren
Installieren
JavaScript ist deaktiviert. Für eine bessere Darstellung aktiviere bitte JavaScript in deinem Browser, bevor du fortfährst.
Du verwendest einen veralteten Browser. Es ist möglich, dass diese oder andere Websites nicht korrekt angezeigt werden.
Du solltest ein Upgrade durchführen oder einen
alternativen Browser
verwenden.
Antworten auf deine Fragen:
Neues Thema erstellen
Start
Forum
Sonstiges
Webdesign, Webentwicklung & Programmierung
PHP, Javascript, jQuery, Ajax, nodeJS, MySQL...
jquery Scrollviewer scrollt nur vertikal
Beitrag
<blockquote data-quote="susiH" data-source="post: 2114316" data-attributes="member: 254055"><p>Hallo,</p><p></p><p>ich habe mal wieder ein Problem bei einer Website. </p><p></p><p>Folgendes habe ich vor. Ich will eine Karte auf einer Website einbauen. Die Karte ist 2000 x 1000px groß. der angezeigte Ausschnitt 700 x 500 px. Nun will ich, dass man mit der Maus in die Karte klickt und sich so der Kartenausschnitt verschieben lässt. Dazu hab ich auch schon ein tolles script mit jquery gefunden, der sogar funktioniert aber einen Haken hat. Die Karte lässt sich nur vertikal verschieben und nicht horizontal. </p><p></p><p>ich habe den code aus dem skript mal hier rein kopiert zur Fehleranalyse <img src="/styles/default/xenforo/smilies/motz.gif" class="smilie" loading="lazy" alt=":motz:" title="Motz :motz:" data-shortname=":motz:" /></p><p></p><p>[PHP](function () {</p><p> function ScrollView() { this.initialize.apply(this, arguments) }</p><p> ScrollView.prototype = {</p><p> initialize: function (container, config) {</p><p> // setting cursor.</p><p> var gecko = navigator.userAgent.indexOf("Gecko/") !== -1;</p><p> var opera = navigator.userAgent.indexOf("Opera/Mac OS/Mac OS") !== -1;</p><p> var mac = navigator.userAgent.indexOf("Mac OS") !== -1;</p><p> if (opera) {</p><p> this.grab = "default";</p><p> this.grabbing = "move";</p><p> } else if (!(mac && gecko) && config) {</p><p> if (config.grab) {</p><p> this.grab = "url(\"" + config.grab + "\"),default";</p><p> }</p><p> if (config.grabbing) {</p><p> this.grabbing = "url(" + config.grabbing + "),move";</p><p> }</p><p> } else if (gecko) {</p><p> this.grab = "-moz-grab";</p><p> this.grabbing = "-moz-grabbing";</p><p> } else {</p><p> this.grab = "default";</p><p> this.grabbing = "move";</p><p> }</p><p> </p><p> // Get container and image.</p><p> this.m = $(container);</p><p> this.i = this.m.children().css("cursor", this.grab);</p><p> </p><p> this.isgrabbing = false;</p><p> </p><p> // Set mouse events.</p><p> var self = this;</p><p> this.i.mousedown(function(e) {</p><p> self.startgrab();</p><p> this.xp = e.pageX;</p><p> this.yp = e.pageY;</p><p> return false;</p><p> }).mousemove(function(e) {</p><p> if (!self.isgrabbing) return true;</p><p> self.scrollTo(this.xp - e.pageX, this.yp - e.pageY);</p><p> this.xp = e.pageX;</p><p> this.yp = e.pageY;</p><p> return false;</p><p> })</p><p> .mouseout(function(){ self.stopgrab() })</p><p> .mouseup(function(){ self.stopgrab() })</p><p> .dblclick(function(){</p><p> var _m = self.m;</p><p> var off = _m.offset();</p><p> var dx = this.xp - off.left - _m.width() / 2;</p><p> if (dx < 0) {</p><p> dx = "+=" + dx + "px";</p><p> } else {</p><p> dx = "-=" + -dx + "px";</p><p> }</p><p> var dy = this.yp - off.top - _m.height() / 2;</p><p> if (dy < 0) {</p><p> dy = "+=" + dy + "px";</p><p> } else {</p><p> dy = "-=" + -dy + "px";</p><p> }</p><p> _m.animate({ scrollLeft: dx, scrollTop: dy },</p><p> "normal", "swing");</p><p> });</p><p> </p><p> this.centering();</p><p> },</p><p> centering: function(){</p><p> var _m = this.m;</p><p> var w = this.i.width() - _m.width();</p><p> var h = this.i.height() - _m.height();</p><p> _m.scrollLeft(w / 2).scrollTop(h / 2);</p><p> },</p><p> startgrab: function(){</p><p> this.isgrabbing = true;</p><p> this.i.css("cursor", this.grabbing);</p><p> },</p><p> stopgrab: function(){</p><p> this.isgrabbing = false;</p><p> this.i.css("cursor", this.grab);</p><p> },</p><p> scrollTo: function(dx, dy){</p><p> var _m = this.m;</p><p> var x = _m.scrollLeft() + dx;</p><p> var y = _m.scrollTop() + dy;</p><p> _m.scrollLeft(x).scrollTop(y);</p><p> }</p><p> };</p><p> </p><p> jQuery.fn.scrollview = function(config){</p><p> return this.each(function(){</p><p> new ScrollView(this, config);</p><p> });</p><p> };</p><p>})(jQuery);</p><p>[/PHP]</p><p></p><p>Da ich dieser Programmiersprache kaum mächtig bin, finde ich auch keinen Fehler. </p><p></p><p>Danke schon mal an euch im Voraus für eure Mühen...</p></blockquote><p></p>
[QUOTE="susiH, post: 2114316, member: 254055"] Hallo, ich habe mal wieder ein Problem bei einer Website. Folgendes habe ich vor. Ich will eine Karte auf einer Website einbauen. Die Karte ist 2000 x 1000px groß. der angezeigte Ausschnitt 700 x 500 px. Nun will ich, dass man mit der Maus in die Karte klickt und sich so der Kartenausschnitt verschieben lässt. Dazu hab ich auch schon ein tolles script mit jquery gefunden, der sogar funktioniert aber einen Haken hat. Die Karte lässt sich nur vertikal verschieben und nicht horizontal. ich habe den code aus dem skript mal hier rein kopiert zur Fehleranalyse :motz: [PHP](function () { function ScrollView() { this.initialize.apply(this, arguments) } ScrollView.prototype = { initialize: function (container, config) { // setting cursor. var gecko = navigator.userAgent.indexOf("Gecko/") !== -1; var opera = navigator.userAgent.indexOf("Opera/Mac OS/Mac OS") !== -1; var mac = navigator.userAgent.indexOf("Mac OS") !== -1; if (opera) { this.grab = "default"; this.grabbing = "move"; } else if (!(mac && gecko) && config) { if (config.grab) { this.grab = "url(\"" + config.grab + "\"),default"; } if (config.grabbing) { this.grabbing = "url(" + config.grabbing + "),move"; } } else if (gecko) { this.grab = "-moz-grab"; this.grabbing = "-moz-grabbing"; } else { this.grab = "default"; this.grabbing = "move"; } // Get container and image. this.m = $(container); this.i = this.m.children().css("cursor", this.grab); this.isgrabbing = false; // Set mouse events. var self = this; this.i.mousedown(function(e) { self.startgrab(); this.xp = e.pageX; this.yp = e.pageY; return false; }).mousemove(function(e) { if (!self.isgrabbing) return true; self.scrollTo(this.xp - e.pageX, this.yp - e.pageY); this.xp = e.pageX; this.yp = e.pageY; return false; }) .mouseout(function(){ self.stopgrab() }) .mouseup(function(){ self.stopgrab() }) .dblclick(function(){ var _m = self.m; var off = _m.offset(); var dx = this.xp - off.left - _m.width() / 2; if (dx < 0) { dx = "+=" + dx + "px"; } else { dx = "-=" + -dx + "px"; } var dy = this.yp - off.top - _m.height() / 2; if (dy < 0) { dy = "+=" + dy + "px"; } else { dy = "-=" + -dy + "px"; } _m.animate({ scrollLeft: dx, scrollTop: dy }, "normal", "swing"); }); this.centering(); }, centering: function(){ var _m = this.m; var w = this.i.width() - _m.width(); var h = this.i.height() - _m.height(); _m.scrollLeft(w / 2).scrollTop(h / 2); }, startgrab: function(){ this.isgrabbing = true; this.i.css("cursor", this.grabbing); }, stopgrab: function(){ this.isgrabbing = false; this.i.css("cursor", this.grab); }, scrollTo: function(dx, dy){ var _m = this.m; var x = _m.scrollLeft() + dx; var y = _m.scrollTop() + dy; _m.scrollLeft(x).scrollTop(y); } }; jQuery.fn.scrollview = function(config){ return this.each(function(){ new ScrollView(this, config); }); }; })(jQuery); [/PHP] Da ich dieser Programmiersprache kaum mächtig bin, finde ich auch keinen Fehler. Danke schon mal an euch im Voraus für eure Mühen... [/QUOTE]
Bilder bitte
hier hochladen
und danach über das Bild-Icon (Direktlink vorher kopieren) platzieren.
Zitate einfügen…
Authentifizierung
Wenn ▲ = 5, ▼ = 2 und ■ = 7, was ist ▲ × ▼ + ■?
Antworten
Start
Forum
Sonstiges
Webdesign, Webentwicklung & Programmierung
PHP, Javascript, jQuery, Ajax, nodeJS, MySQL...
jquery Scrollviewer scrollt nur vertikal
Oben