MediaWiki:Common.js: Difference between revisions

From Haven Homes
(Created page with "→‎Any JavaScript here will be loaded for all users on every page load.: const panoContainer = document.getElementById('panorama'); const panoImage = document.getElementById('panoImage'); let isPanning = false; let startX = 0; let scrollLeft = 0; panoContainer.addEventListener('mousedown', (e) => { isPanning = true; startX = e.pageX - panoContainer.offsetLeft; scrollLeft = panoContainer.scrollLeft; panoContainer.style.cursor = 'grabbing'; }); panoContainer....")
 
mNo edit summary
Line 4: Line 4:
const panoImage = document.getElementById('panoImage');
const panoImage = document.getElementById('panoImage');


let isPanning = false;
var isPanning = false;
let startX = 0;
var startX = 0;
let scrollLeft = 0;
var scrollLeft = 0;


panoContainer.addEventListener('mousedown', (e) => {
panoContainer.addEventListener('mousedown', (e) => {

Revision as of 10:06, 6 November 2023

/* Any JavaScript here will be loaded for all users on every page load. */

const panoContainer = document.getElementById('panorama');
const panoImage = document.getElementById('panoImage');

var isPanning = false;
var startX = 0;
var scrollLeft = 0;

panoContainer.addEventListener('mousedown', (e) => {
  isPanning = true;
  startX = e.pageX - panoContainer.offsetLeft;
  scrollLeft = panoContainer.scrollLeft;
  panoContainer.style.cursor = 'grabbing';
});

panoContainer.addEventListener('mouseleave', () => {
  isPanning = false;
  panoContainer.style.cursor = 'grab';
});

panoContainer.addEventListener('mouseup', () => {
  isPanning = false;
  panoContainer.style.cursor = 'grab';
});

panoContainer.addEventListener('mousemove', (e) => {
  if (!isPanning) return;
  e.preventDefault();
  const x = e.pageX - panoContainer.offsetLeft;
  const walk = (x - startX);
  panoContainer.scrollLeft = scrollLeft - walk;
});
This site is in the process of being built; content may not be accurate or complete. Please contact us if you see an error.
No AI or LLM tools were used to generate any text or images on this site. If they had been, the site would be complete and look better.