Android wheel scroll second wheel when the first is scrolled
Tag : java , By : mansoor
Date : March 29 2020, 07:55 AM
With these it helps I think the best solution is to use a flag to skip duplicated events from the wheels; something like next: changedlistener = new OnWheelChangedListener() {
boolean inProgress = false;
public void onChanged(WheelView wheel, int oldValue, int newValue) {
if (!inProgress) {
return;
}
inProgress = true;
try {
if (wheel.getId() == R.id.month || wheel.getId() == R.id.day || wheel.getId() == R.id.year) {
updateDays(year, month, day);
} else if (wheel.getId() == R.id.hijrimonth || wheel.getId() == R.id.hijriday || wheel.getId() == R.id.hijriyear) {
hijriDays(hijriyear, hijrimonth, hijriday);
}
}
finally {
inProgress = false;
}
}
};
|
cross browser mouse wheel, to scroll 100% browser height by one single wheel
Date : March 29 2020, 07:55 AM
I hope this helps you . Have some js , I use mouswheel.js and I do it! :) may be useful for someone $(document).ready(function(){
var winHeight = window.innerHeight ?
function() {
return window.innerHeight;
} :
function() {
return document.documentElement.clientHeight;
};
$('.first-block').height(winHeight);
var BlockHeight = $('.first-block').height();
$.browser = {};
$.browser.mozilla = /mozilla/.test(navigator.userAgent.toLowerCase()) && !/webkit/.test(navigator.userAgent.toLowerCase());
if($.browser.mozilla)
{
var ScrollType = 'html';
}
else
{
var ScrollType = 'body';
}
$('.first-block').mousewheel(function(event, delta, deltaX, deltaY) {
if((delta<0) && ($(ScrollType).scrollTop()==0)) $(ScrollType).animate({ scrollTop: BlockHeight- 104 }, 600);
});
$(ScrollType).keydown(function(event){
if((event.keyCode==40) && ($(ScrollType).scrollTop()==0)) $(ScrollType).animate({ scrollTop: BlockHeight-104 }, 600);
})
});
|
jQuery scroll event: how to determine amount scrolled (scroll delta) in pixels?
Date : March 29 2020, 07:55 AM
Any of those help The "scroll value" does not depend on the window size or screen resolution. The "scroll value" is simply the number of pixels scrolled. However, whether you are able to scroll at all, and the amount you can scroll is based on available real estate for the container and the dimensions of the content within the container (in this case the container is document.documentElement, or document.body for older browsers). // custom 'scrolldelta' event extends 'scroll' event
jQuery.event.special.scrolldelta = {
delegateType: "scroll",
bindType: "scroll",
handle: function (event) {
var handleObj = event.handleObj;
var targetData = jQuery.data(event.target);
var ret = null;
var elem = event.target;
var isDoc = elem === document;
var oldTop = targetData.top || 0;
var oldLeft = targetData.left || 0;
targetData.top = isDoc ? elem.documentElement.scrollTop + elem.body.scrollTop : elem.scrollTop;
targetData.left = isDoc ? elem.documentElement.scrollLeft + elem.body.scrollLeft : elem.scrollLeft;
event.scrollTopDelta = targetData.top - oldTop;
event.scrollTop = targetData.top;
event.scrollLeftDelta = targetData.left - oldLeft;
event.scrollLeft = targetData.left;
event.type = handleObj.origType;
ret = handleObj.handler.apply(this, arguments);
event.type = handleObj.type;
return ret;
}
};
// bind to custom 'scrolldelta' event
$(window).on('scrolldelta', function (e) {
var top = e.scrollTop;
var topDelta = e.scrollTopDelta;
var left = e.scrollLeft;
var leftDelta = e.scrollLeftDelta;
// do stuff with the above info; for now just display it to user
var feedbackText = 'scrollTop: ' + top.toString() + 'px (' + (topDelta >= 0 ? '+' : '') + topDelta.toString() + 'px), scrollLeft: ' + left.toString() + 'px (' + (leftDelta >= 0 ? '+' : '') + leftDelta.toString() + 'px)';
document.getElementById('feedback').innerHTML = feedbackText;
});
#content {
/* make window tall enough for vertical scroll */
height: 2000px;
/* make window wide enough for horizontal scroll */
width: 2000px;
/* visualization of scrollable content */
background-color: blue;
}
#feedback {
border:2px solid red;
padding: 4px;
color: black;
position: fixed;
top: 0;
height: 20px;
background-color: #fff;
font-family:'Segoe UI', 'Arial';
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id='feedback'>scrollTop: 0px, scrollLeft: 0px</div>
<div id='content'></div>
|
How to write mouse wheel scroll event when wheel (middle) button held down?
Tag : vb.net , By : user183442
Date : March 29 2020, 07:55 AM
To fix this issue You need to handle more than one event. You need to capture the MouseWheel event and the MouseDown/MouseUP events. Private mouseDown As Boolean = False
Private Sub Form1_MouseWheel(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel
If e.Delta > 0 And mouseDown Then
Console.WriteLine("Scrolling with button down")
Else
Console.WriteLine("Button Not down whilst scrolling")
End If
End Sub
Private Sub Form1_MouseDown(sender As Object, e As MouseEventArgs) Handles MyBase.MouseDown
If e.Button = MouseButtons.Middle Then
mouseDown = True
End If
End Sub
Private Sub Form1_MouseUp(sender As Object, e As MouseEventArgs) Handles MyBase.MouseUp
If e.Button = MouseButtons.Middle Then mouseDown = False
End Sub
|
infinite scroll firing too quickly with cursor, but fine with space bar or scroll wheel
Date : March 29 2020, 07:55 AM
Does that help I'm trying to learn React by implementing a custom infinite scroll. , You could set a flag, say allowScroll: constructor(props) {
super(props);
this.state = {
visibleStart: 0,
visibleEnd: 20,
diff: 20
};
this.allowScroll = true;
}
handleScroll(event) {
if (!this.allowScroll) {
return;
}
this.allowScroll = false;
setTimeout(function() {
this.allowScroll = true;
}, 1000);
// ...
}
|