How to Hide the up or down arrow key when scrolling at the end of the Jscrollpane - jscrollpane

I used the JScrollPane from http://jscrollpane.kelvinluck.com/ and modified it to hide the arrow key when scrolling at the end (top or bottom). When scrollbar is at the top, the arrowUp should disappear, showing only arrowDown at the bottom and appears again when scrolling down.
I've made the arrow image disappear at the top, but the problem is the scroll track does not change but just adds extra space equal to the size of the arrow image at the very bottom. How can I go around this, how do I change it so that when the arrow is hidden at one end, the jspTrack's height is adjusted as well, showing the other arrow on the opposite end without extra space?
if (settings.showArrows) {
if(isAtTop){
arrowUp.addClass('jspDisabled');
arrowUp.css('display', 'none');
}
else{
arrowUp.removeClass('jspDisabled');
arrowUp.css('display', 'block');
}
if(isAtBottom){
arrowDown.addClass('jspDisabled');
arrowDown.css('display', 'none');
}
else{
arrowUp.removeClass('jspDisabled');
arrowDown.css('display', 'block');
}
/*arrowUp[isAtTop ? 'addClass' : 'removeClass']('jspDisabled');
arrowDown[isAtBottom ? 'addClass' : 'removeClass']('jspDisabled');*/
}
Thanks all.

you can control it via css
<style>
.jspVerticalBar{
background:none;
}
.jspVerticalBar .jspArrow{
display:block;
}
.jspVerticalBar .jspDisabled
{
display:none;
}
</style>
JavaScript:
<script>
$('.pane').jScrollPane({showArrows:true});
</script>

Related

tooltip's aren't "centered" despite direction: center being set

I'm creating labels for polygons with the following code:
L.marker(polygon.getBounds().getCenter())
.bindTooltip('County Name', {permanent: true, direction: 'center'})
.addTo(mymap);
However, the result isn't exactly what I'd call centered. Like the majority of the tooltip is on the right side of the marker whereas I'd expect the marker to be smack dab in the middle of the tooltip.
Any ideas as to what I can do to improve the situation?
If I can get this working I'll hide the marker by doing {opacity: 0} but if I do that now it'll look off center without a frame of reference.
If you want to add labels to the polygon you can use instead customised Tooltip.
In your Javascript code :
let custom_popup = L.popup()
.setLatLng(polygon.getBounds().getCenter())
.setContent('County name')
.addTo(map);
Then you can customise to make it look like a Marker using CSS :
.leaflet-popup-close-button // we remove the X to close the popup
{
display: none;
}
.leaflet-popup-tip // We remove the arrow pointing at the coordinates
{
display: none;
}
.leaflet-popup-content // We center the text inside the Tooltip
{
text-align: center;
}
Here's the result :

How I make sticky nav bar which has responsive element without specific height above it?

So I have 100% of screen width header image at the top of the page and text element below the image. Below the text element I tried to make sticky navigation bar with this code:
$(function(){
var stickyRibbonTop = $('#stickyribbon').offset().top;
$(window).scroll(function(){
if( $(window).scrollTop() > stickyRibbonTop ) {
$('#stickyribbon').css({position: 'fixed', top: '0px'});
} else {
$('#stickyribbon').css({position: 'static', top: '0px'});
}
});
});
Problem is that sticky nav bar jumps to the top of the page already when I scroll down the height of the text element. So it totally ignores the header image. I have height auto for this image but it obviously does nothing.
Solved it by myself. Solution was to make div with no height and padding-bottom as percentage of header image's height to its width and put the image in that div.

Prevent Mobile Safari from scrolling address bar into view when clicking on top of the page

I have a webapp that on load performs window.scrollTo(0, 1); to hide the address bar which is working.
One of the elements is a header with fixed positioning of top: 0, causing it to stay topmost of the viewport. On this header there are a few clickable buttons, when you try to click them, instead of performing the action it scrolls the address bar into view.
This is a default safari behavior for the click on the top 15-20 pixels of the screen.
I have tried to capture the clicks and cancel the event, cancel bubbling, prevent default etc. None of which seemed to work.
The code I tried was adding a div with id test:
#test {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 20px;
}
document.getElementById("test").addEventListener("click", function (event) {
event.preventDefault();
event.stopPropagation();
}, false);
Any ideas?
I use this for preventing default on mobile:
https://github.com/alexblack/google-fastbutton
$('#your-button').fastClick(function(e) {
e.preventDefault();
});
No address bar is shown. Pretty neat for UX also

Winjs Flyout in the center of the screen

When I click on a button, a Flyout will appear for confirmation on the top of the button I have just clicked on.
I tried this :
flyout.alignment="center"
but the alignment is by the button. I want to show my flyout in the center of my screen. I'm asking if this is possible with Winjs.UI.Flyout
Flyout is always aligned wrt to the element passed as the first parameter. If you need to have the flyout not aligned to the element but at the center of the screen, it can be done by placing an hidden element at the center of the screen and aligning the flyout to it.
_oncmdclick: function oncmdclick(event)
{
// assume an element with class hidden in the page and placed at center of the screen
var hiddenElement = this.element.querySelector('.hidden');
var myFlyoutElement = ...; // myFlyoutElement is the flyout element
this.newItemFlyoutElement.winControl.show(hiddenElement, 'top', 'center');
},
html:
<div class="hidden" style="visibility: collapse"></div>
css:
// in this case, I had used 1x1 -ms-grid for the section of the page
.mypage.fragment section[role=main] {
display: -ms-grid;
-ms-grid-rows: 1fr;
-ms-grid-columns: 1fr;
}
// center the hidden element in the page grid
.mypage.fragment section[role=main] .hidden
{
-ms-grid-column-align: center;
-ms-grid-row-align: center;
}

How to have multiple toggle at the same time for 2 different div?

I need to handle multiple slide toggle for 2 different divs using jquery.
example: when I click a button, it should slideLeft the 1st div and at the same time it should expand the 2nd div covering the whole area of the 1st div.
Thanks in advance.
Here the piece of code I have used:
$(document).ready(function() {
$('#foo').click(function() {
$('#accordian').toggle("slide", 300);
if ($(this).val() == "Hide Menu"){
$(this).val("Show Menu");
$('#area').css({"max-width":"960px"});
}else{
$(this).val("<< Hide Menu");
$('#area').css({"max-width":"730px"});
}
});