Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [ajax]Zakończenie akcji po onmousemove/onmousedown
MaciekDZN
post 18.01.2018, 13:41:30
Post #1





Grupa: Zarejestrowani
Postów: 84
Pomógł: 0
Dołączył: 6.01.2008
Skąd: Działoszyn

Ostrzeżenie: (0%)
-----


Nie mam pojęcia jak zatrzymać wykonywany skrypt
Link do Live na w3schools.com

kod:
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
  4. <!-- Copyright Š 2008 nexis.pl -->
  5. <head>
  6. <title>Współrzędne myszki</title>
  7. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  8. <script type="text/javascript">
  9.  
  10. function przesunstop(u){
  11. przesun(u);
  12. }
  13. function przesun(a){
  14. if(a==1){
  15. var IE = document.all ? true : false;
  16. if (!IE) document.captureEvents(Event.MOUSEMOVE);
  17. document.onmousemove = getMouseXY;
  18. var tempX = 0;
  19. var tempY = 0;
  20. function getMouseXY(e) {
  21. if (IE) {
  22. tempX = event.clientX + document.body.scrollLeft;
  23. tempY = event.clientY + document.body.scrollTop;
  24. } else {
  25. tempX = e.pageX;
  26. tempY = e.pageY;
  27. }
  28. if (tempX < 0){
  29. tempX = 0;
  30. }
  31. if (tempY < 0){
  32. tempY = 0;
  33. }
  34. document.getElementById("x").value = tempX;
  35. document.getElementById("y").value = tempY;
  36. var xxx = 5;
  37. if(tempX>300){
  38. xxx = 300; }else{ xxx = tempX;}
  39. document.getElementById("obiekt2").style.left = xxx+'px'; document.getElementById("oxy").value=document.getElementById("obiekt2").style.left;
  40. document.getElementById("obiekt1").style.left = xxx+'px';
  41. }
  42. }
  43. }
  44.  
  45.  
  46. </script>
  47. </head>
  48. <body onmouseup="przesunstop(0)">
  49. <div>
  50. <input type="text" id="x" />
  51. <input type="text" id="y" />
  52. <br>
  53. <img src='http://forum.php.pl/style_images/upgrade_ip/f_hot.gif' style='position: absolute;' id="obiekt2">
  54. <br>
  55. <input id="obiekt1" style='position: absolute;' type="button" onmousedown="przesun(1)" value='->' onmouseup="przesunstop(0)">
  56. <br><br>
  57. <input type="text" id="oxy" />
  58. </div>
  59. </body>
  60. </html>
Go to the top of the page
+Quote Post
nospor
post 18.01.2018, 14:00:23
Post #2





Grupa: Moderatorzy
Postów: 36 441
Pomógł: 6290
Dołączył: 27.12.2004




A jaki to ma wg ciebie zwiazek z AJAX? Przenosze


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
MaciekDZN
post 18.01.2018, 14:16:09
Post #3





Grupa: Zarejestrowani
Postów: 84
Pomógł: 0
Dołączył: 6.01.2008
Skąd: Działoszyn

Ostrzeżenie: (0%)
-----


Nie zauważyłem tego działu więc dodałem do ajaxa wink.gif wiem że to czyste js smile.gif sorrki za bład

ps

po naciśnieciu na przycisk "obiekt1" i przesuniąciu myszką to zdjęcie "obiekt2" przesunie się w prawo aż do granicy ustalonej 300px
ale gdy puści się przycisk myszy to obiekt 1 i 2 nadal poruszają się za kursorem - w tym problem ze po puszczeniu mają przestać smile.gif
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 16.04.2024 - 09:44