Masonry / Infinite scroll "jump flickers" on page load when positioned - jquery-masonry

Preface: Masonry is a JQuery plug in that creates a "brick-style" layout of html pages on one page. Infinite scroll is a plug in that allows for a pintrest-style scrolling of page items.
I have masonary w/ infinite scroll installed here:
http://helpknow.com/black2/
and my problem is this.
I want to position the "container" div to center the entire list of items in the page.
So I use some code like this:
#container {
left:140px; // <---- Positioning
padding:10px;
background: #FFF;
padding: 5px;
margin-bottom: 20px;
border-radius: 5px;
clear: both;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
The problem is when I do that, upon opening the page there is a quick "flickering jump" where all the masonry items move to their position ( you might not be able to see it on refresh, only on initial page load). I don't want this. I want the items to not "flicker". I want them to appear static until the user scrolls, then I want the animation to take place as expected. When I remove the left positioning this problem does not happen (but obviously the items float left and are not centered, which is not what I want). I tried wrapping the main div "container" and other items in a new div container and moving it/them around and was met with the same problem.

Have you tried 2, meaning to initialise Masonry when all your content has been loaded? Now, you are doing it as in 1...
1 This executes, when the DOM has been constructed, before all content has been loaded
$(document).ready(function(){ ... });
$(function(){...}); // short form
2 This executes, when all content has been loaded
$(window).load(function(){ ... });
3 This executes immediately, when it is first encountered by the browser
(function(){ ... })();
The latter is a self-executing anonymous function (known as a closure), which is very handy, but not here, because no content or not the right content may have been loaded when it self-executes.
UPDATE Alternatively, you can fade your #container in, which can sometimes look nice, too. See this fiddle here, which does the same with Masonry's bigger brother Isotope.

Related

Bookmarks drop user off at wrong page

When clicking on a public or private bookmark, Spotfire takes the user to the page that the user was on DIRECTLY BEFORE he or she created the bookmark. If the user were to select the bookmark again, it would then take them to the correct page, with the correct measures loaded.
This happens whether the GUI bookmark is clicked, or a bookmark link is clicked. In fact, if a link is clicked, it is almost impossible to get to the correct bookmark page (the user has to click very fast).
After a ton of trial and error, I limited it down to some HTML/Javascript functionality. In this dashboard, users navigate by using a custom navigation bar. If a user creates a bookmark, changes pages using the custom navigation bar, then clicks on the bookmark, it will not work correctly. If a user creates the bookmark, clicks the page tab then clicks on the bookmark, it will work correctly. I used the code here to build the python script that changes pages (kicked off by a changing Document Property). I was able to reproduce this bug in the sample spotfire reports. The below HTML code is for the Nav bar:
<style>
.topnav {
overflow: hidden;
background-color: #313814A;
}
.topnav a {
float: left;
color: #f2f2f2;
text-align: center;
padding: 5px 16px;
text-decoration: none;
font-size: 16px;
font-family:Calibri;
}
.topnav a:hover {
background-color: #ddd;
color: black;
cursor: pointer;
}
.topnav a.active {
background-color: #ddd;
color: black;
}
</style>
<div class="topnav">
<a onclick="SBAReporting()">Reports</a>
</div>
<!-- input field that changes the Doc Prop that fires off the python script-->
<div id="navigateToPage" style="display:none"><SpotfireControl id="f9cc2258568d415383d842064287993a" /></div>
<script>
function SBAReporting() {
randInt = Math.floor(Math.random() * (100+1))
myJSObject = "Reporting";
document.getElementById('navigateToPage').firstChild.value = myJSObject + randInt;
$("#navigateToPage input").focus();
$("#navigateToPage input").blur();
}
</script>
My theory on what is happening is the following:
User clicks on the custom HTML/Python navigation to get back to a page. Spotfire has some internal variable that does not get set correctly.
The user selects the bookmark. Spotfire thinks they are already on the correct page so it does not navigate there. Part of the bookmark process sets that mystery variable correctly.
The second time clicked, that variable is set correctly, spotfire knows what page you are on, and it works correctly.
I tried to refresh the entire page (and hopefully that variable) by adding location.reload(); but that did not work. Is there a way to let Spotfire refresh the page? Any insight on what may not be updating correctly?
tl;dr It seems that the pythonic way to change pages in Spotfire does not alter some behind the scenes variable to let Spotfire know what page the user is truly on. This happens with sample Spotfire provided reports and Spotfire provided Python Scripts. I need a better way of letting Spotfire know what page a user is on.
UPDATE A defect has been logged with TIBCO. Still open to work-arounds.

Many svg's near with each other as clickable icons

I have many icons svg, I could use them as fonts if that is helpful and I would like to use ng-click(basically any kinda of click you know) the way that when i click on svg1 and svg2 wont be clicked. Till now i have tried allot of icons and many ways of doing it without success. I have upload to codepen small example, each region of that country have it's own svg which cover other svg's and make click on them impossible. Basic use of svg is below:
<svg>
<use xlink:href="#icon-region"></use>
</svg>
Since all <svg> elements in your page are absolute positioned and have both width and height of 100%, it's possible to only catch elements from the last element. That behavior comes from the way elements are rendered, within layers, like the example bellow:
+-<svg>--+
|+-<svg>--+
||+-<svg>--+
||| |
+|| |
+| |
+--------+
If all those elements have the same width, height and position you can only catch events from the last one, on the top of all.
To avoid this behavior you can do the following, with CSS:
.regionPosition {
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
pointer-events: none;
}
.regionPosition > * {
pointer-events: all;
}
This way you disable the event listening from <svg> elements – with regionPosition class – and catch only the events from their immediate children.
Since you're using <use> inside your SVG to get the actually graphics, you can't rely only on Angular to bind the event, because the elements are not yet there when you load the script. You'll need to attach the event listener to the document and then check the target before call the function you want. This can be easily done with jQuery, as follows:
jQuery(document).on('click', '.regionPosition > *', function () {
// Call your function.
});
I changed your code a bit to show how to do it, here: http://codepen.io/anon/pen/waLwrm. I'm using a simple window.console.log() call to just log the clicked element. You can change it to another logic in your final code.
Reference:
jQuery hover problem due to z-index

Content hiding behind left side menu

The content of my webpage is going behind the side menu I have positioned to the left.I want the menu to be fixed however whenever I do so the content hides behind the menu to the left. Any help would be much appreciated. (Apologies for formatting, new to the site.)
.menu {
padding-top: 150px;
height: 100%;
width: 170px;
background-color: white;
float: left;
display: table;
position: fixed;
}
Fixed elements are no longer within the page flow, they act in the same way as an absolute positioned element. Chris Coyier has a really good explanation about the differences in positioning http://css-tricks.com/absolute-relative-fixed-positioining-how-do-they-differ/
In order for your body content to stop flowing behind the fixed property, you need to create a container (if one does not exist yet) that all of the body content resides in, except of course the nav/menu bar. You then apply a padding-left to the main body content equal so the width of the fixed element so that the main body content is always padded away from the left of the browser.
Fixed elements don't affect the flow and positioning of elements and position:relative on a parent container has no affect on a fixed element.

Different Styling for Captions on Two Different Nivo Sliders on One Page

I am trying to put two Nivo sliders on one page. Some of the attributes are different. So I have simply created two scripts for these attributes, "slider" and "slider2". That's no problem.
However, I want to make the title style a little different for the second slider. I noticed that the text style of the slide title is controlled by this style:
.nivo-caption p {
padding:8px;
margin:0;
color: #000;
font-size: 16px;
}
However, I don't see that css style called within my html. (When I look at the web page source code I see it but not when I'm actually looking at the code file itself.)
I'd love to simply create a new style for my second slider, something like:
.nivo-caption2 p {
margin:0;
color: #000;
font-size: 12px;
}
But I need to know how to actually call that within my html. Can anyone help? Thanks.
Actually, I figured it out. Since I have ids of "slide" and "slide2" for each slide show, I simply appended that to my new style and that worked.

CS6 Fluid Grids 3 types of background 100% wide?

I'm new to fluid grids, btw i'v started learning about diferent types and now trying to build page in cs6 (maybe not the right choice). I have a problem which I didn't have when building pages that are not fluid. I need to create different background images for header and footer that are 100% width and as wide as the screen, not just as wide as media-query, and also to setup the page to be 960 centered.
Are you trying to make the header wider than the rest of the page?
To do so, create different div's in the document. For example, I normally work all of my divs inside a master div, so that my entire page is affected. For example, a page with a main div, header, body, and footer:
#main #header #body #footer. The header, body, and footer are all create inside of the main div. To make everything float in the center of the page at a width of 960px, then you'd simply apply the attribute to the #main div like so:
#main {
width: 960px;
margin: 0;
}
The margin will cause the div to float in the center. It does not have to be any specific value, but you do need a margin to the left and right of the page.
To only float the remainder of the page, create everything else inside of the main div but the header and footer, and set the width of the header to 100%. So you would have the following overall snippet:
#header, #footer{
width: 100%;
margin: 0;
}
#main {
width: 960px;
margin: 0;
}
If you don't already do so, it'd be wise to add some padding on either side so that the images and text don't appear to run into the side of the page (which makes it difficult to read or view). 5px is usually all I add.

Resources