On adding new element on the last child of my `container' on the time scroll appears. I'd like to scroll-down to put the new element on browser view.
I tried using '$anchorScroll` but that doesn't work.
HTML
<div class="galleryMenu">
<!-- <a class="live" ng-click="galleryMenu('live')" href="#">live</a>
<a class="visual" ng-click="galleryMenu('visual')" href="#">visuals</a> -->
<a class="projects" ng-click="galleryMenu('projects')" href="#">projects</a> //clicking and calling galleryMenu function
</div>
<!-- Focus needs to be applied here, height of element is 180px -->
<div class="appGallery" ng-show="galleryShow" id="anchor3">
<a ng-click="galleryChanger('prev')" class="prev" href="#">prev</a>
<a ng-click="galleryChanger('next')" class="next" href="#">next</a>
</div>
JS
"use strict";
angular.module("tcpApp")
.run(['$anchorScroll', function($anchorScroll) {
$anchorScroll.yOffset = 180; //running here.
}])
.controller("homeController", ['$scope','server', '$anchorScroll', '$location', function ($scope, server, $anchorScroll, $location) {
$scope.galleryMenu = function (gallery) {
var newHash = 'anchor3';
if ($location.hash() !== newHash) {
$location.hash('anchor3');
} else {
$anchorScroll();
}
}]);
Related
I'm not sure why this is happening. I'm using two separate modals with two separate scripts that are identifying two separate classes. The first is the "Specials" Modal Window and the second is the "Emergency" Modal Window. Yet when I click the "Specials" links the "Emergency" Modal window opens. When I click the Emergency model window, it opens fine. How can this be fixed so that it works as intended? Thanks in advance for your assistance.
HTML & JQUERY for First Modal Window
<div class="flip-container" ontouchstart="this.classList.toggle('hover');">
<div class="flipper">
<div class="front_03">
<img src="./images/free.png">
</div>
<div class="back_03">
<a class="button-to-click" href="#">
Blah...Blah..
Blah...Blah..<br />
[ CLICK HERE ]
</a>
</div>
</div>
</div>
<div class="popup-container">
<div class="specials_title">BLAH TITLE</div>
<p>Blah...Blah...Blah...</p>
<div class="coupon_container">
<p><div class="fa fa-star checked"></div> Blah.. Blah..</p>
<p><div class="fa fa-star checked"></div> Blah.. Blah..</p>
<p><div class="fa fa-star checked"></div> Blah.. Blah..</p>
<p><div class="fa fa-star checked"></div> Blah.. Blah..</p>
</div>
<a class="popup-close closer" href="#">X</a>
</div>
<script>
$(document).ready(function() {
// config
popup = $('.popup-container');
clickme = $('.button-to-click');
// pop-up
vh = $(window).height();
vw = $(window).width();
bw = popup.width();
bh = popup.height();
clickme.click(function(e) {
e.preventDefault();
popup.fadeOut();
popup.css('left', vw/2 - bw/2);
popup.css('top', vh/2 - bh/2);
popup.fadeIn();
});
//close button
$('.popup-close').click(function() {
$('.popup-container').fadeOut();
});
});
</script>
HTML & JQUERY for Second Modal Window
<div class="co_R_content">
<button type="button" class="click_emergency">
<div class="led-content">CLICK HERE</div>
<div class="led-box">
<div class="led-red"></div>
</div>
</button>
</div>
<div class="popup-container popup-emergency">
<div class="emergency_title">EMERGENCY?</div>
<p>Blah...Blah...Blah...</p>
<div class="entry-content">
<div class="wpforms-container">
<form id="wpforms-form">
<--- WPForms HTML Goes Here --->
</form>
</div> <!-- .wpforms-container -->
</div><!-- .entry-content -->
<a class="popup-close closer closer2" href="#">X</a>
</div>
<script>
$(document).ready(function() {
// config
popup = $('.popup-emergency');
clickme = $('.click_emergency');
// pop-up
vh = $(window).height();
vw = $(window).width();
bw = popup.width();
bh = popup.height();
clickme.click(function(e) {
e.preventDefault();
popup.fadeOut();
popup.css('left', vw/2 - bw/2);
popup.css('top', vh/2 - bh/2);
popup.fadeIn();
});
//close button
$('.popup-close').click(function() {
$('.popup-emergency').fadeOut();
});
});
</script>
Renamed the Variables in the second script from popup & clickme to different names and that did the trick.
FROM:
<script>
$(document).ready(function() {
// config
popup = $('.popup-emergency');
clickme = $('.click_emergency');
// pop-up
vh = $(window).height();
vw = $(window).width();
bw = popup.width();
bh = popup.height();
clickme.click(function(e) {
e.preventDefault();
popup.fadeOut();
popup.css('left', vw/2 - bw/2);
popup.css('top', vh/2 - bh/2);
popup.fadeIn();
});
//close button
$('.popup-close').click(function() {
$('.popup-emergency').fadeOut();
});
});
</script>
TO:
<script>
$(document).ready(function() {
// config
popup2 = $('.popup-emergency');
clickme2 = $('.click_emergency');
// pop-up
vh = $(window).height();
vw = $(window).width();
bw = popup2.width();
bh = popup2.height();
clickme2.click(function(e) {
e.preventDefault();
popup2.fadeOut();
popup2.css('left', vw/2 - bw/2);
popup2.css('top', vh/2 - bh/2);
popup2.fadeIn();
});
//close button
$('.popup-close').click(function() {
$('.popup-emergency').fadeOut();
});
});
</script>
I made a hamburger menu, and when I click on the links it closes it. Also has a logo which disappears when I click on the hamburger button.
The webpage has a mobile and a desktop computer version that doesn't have a hamburger menu.
But I have a problem. On the Desktop version, if I click on the links the Logo disappears as well.
I know that it does it because the hamburger-close-after-click event triggers it.
But I don't know how I could change it to make it work well.
jQuery Code
const hamburger = document.querySelector('.hamburger');
const navLinks = document.querySelector('.nav-links');
const links = document.querySelectorAll('.nav-links li');
var mylogo = document.getElementById("myLogo");
hamburger.addEventListener('click', () => {
navLinks.classList.toggle('open');
links.forEach(link =>{
link.classList.toggle("fade");
});
});
//logo-toggle
$(document).ready(function(){
$('.hamburger').click(function() {
$('.logo-container').toggle().delay( 800 );
});
});
// hamburger-close-after-click event
$( '.nav-links li a' ).on("click", function(){
$('#hamburgerID').click();
});
HTML Code
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<nav>
<div class="hamburger" id="hamburgerID">
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
</div>
</nav>
<header class="header" id="myHeader">
<div class="logo-container" id="myLogo">
<img src="./img/logo.png" alt="logo"/>
</div>
<nav>
<ul class="nav-links">
<li><a class="nav-link" href="#details">DETAILS</a></li>
<li><a class="nav-link" href="#description">DESCRIPTION</a></li>
<li><a class="nav-link" href="#aboutus">ABOUT US</a></li>
</ul>
</nav>
The problem with pictures
[
You can use JQuery.toggleClass() to add and remove CSS classes, instead of using JQuery.toggle(), e.g.:
$('.hamburger').click(function() {
$('.logo-container').toggleClass('open');
})
And then, in the CSS file, define the visibility depending on the screen size, e.g.:
.logo-container { display: 'none' }
.logo-container.open { display: 'block' }
#media (min-width: 1025px) {
.logo-container { display: 'block' }
}
(Note: You will want to decide yourself how to identify the appropriate size to hide and show the elements. See also e.g.: how-to-target-desktop-tablet-and-mobile)
I am currently building a website which contains a accordion menu.
My problem is the following, when I click the desired item which has to collapse it does collapse but it goes right back to uncollapsed after it collapsed.
$(document).ready(function(){
$(".set > a").on("click", function(){
if($(this).hasClass('active')){
$(this).removeClass("active");
$(this).siblings('.content').slideUp(200);
$(".set > a i").removeClass("fa-minus").addClass("fa-plus");
}else{
$(".set > a i").removeClass("fa-minus").addClass("fa-plus");
$(this).find("i").removeClass("fa-plus").addClass("fa-minus");
$(".set > a").removeClass("active");
$(this).addClass("active");
$('.content').slideUp(200);
$(this).siblings('.content').slideDown(200);
}
});
});
Here is the code (jsfiddle)
This code used to work perfectly fine, but for some reason it broke and doesn't work anymore.
I hope someone can help me out.
I think somewhere along the lines you have swapped your accordion to start open (ie removed the styles that initially hide it) so the following lines in your else both opens and closes it:
$('.content').slideUp(200);
$(this).siblings('.content').slideDown(200);
If you are starting with your accordion open, then you need to start with the active class on your link:
$(document).ready(function() {
$(".set > a").on("click", function() {
var link = $(this);
if (link.hasClass('active')) {
link.next('.content').slideUp(200, function() {
link.children('i').removeClass("fa-minus").addClass("fa-plus");
link.removeClass("active");
});
} else {
link.next('.content').slideDown(200, function() {
link.children('i').removeClass("fa-plus").addClass("fa-minus");
link.addClass("active");
});
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="accordion-container">
<div class="set">
Vloeren <i class="fa fa-plus"></i>
<div class="content">
<ul class="submenu">
<li class="submenu-item">Witte vloer</li>
<ul class="submenu-two">
<li class="submenu-item">Witte vloer</li>
</ul>
<li class="submenu-item">Zwarte vloer</li>
<li class="submenu-item">Grijze vloer</li>
<li class="submenu-item">Paarse vloer</li>
</ul>
</div>
</div>
</div>
I have also cleaned up your jQuery and fixed your else
I'm using iScroll for a horizontal, fixed position menu. It works great, however I'm unable to vertically scroll the rest of the page in a mobile browser. It works fine in a pc/mac resized browser window, just not on mobile. I've tried Safari on iPhone and Chrome and Dolphin on Android.
Any ideas how I can get the page to scroll too?
I've played with the vScroll, hScroll, etc options but haven't been able to solve the issue:
<nav id="mainNav">
<ul class="pagesIcons bottom">
<li style="background-color:#000000" class="active selected current youarehere">
<a href="#" class="inner">
<div class="buttonIcon">
<img src="/content/icons/002.png">
</div>
<div class="buttonText">
Homepage
</div>
</a>
</li>
<li style="background-color:#383838" class="">
<a href="#" class="inner">
<div class="buttonIcon">
<img src="/content/icons/002.png">
</div>
<div class="buttonText">
Gallery
</div>
</a>
</li>
<li style="background-color:#5c5c5c" class="">
<a href="#" class="inner">
<div class="buttonIcon">
<img src="/content/icons/004.png">
</div>
<div class="buttonText">
Events
</div>
</a>
</li>
........
</ul>
</nav>
I'm initialising it with:
var myScroll;
function loaded() {
myScroll = new iScroll('mainNav', {
bounce: false
});
}
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
document.addEventListener('DOMContentLoaded', loaded, false);
Solved. I just had to remove:
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
Pretty obvious. This was preventing the default event on 'touchmove'. Durrrrrrr
You can fix this issue by applying this jquery, In place of ClassName you have to add the name of wrapper class in which you want scrolling, If you still face problem let me know I will try to help more.
$('.ClassName').bind('touchmove', function(e){
e.stopPropagation();
});
I'm new to Blogger, and HTML and am trying to set up a fashion-blogging website on Blogger.
I've been successful in making the header image static (that is, doesn't move when scrolling through posts), but unfortunately it isn't aligned at the very top of the website. This makes it look very odd as content disappears as it scrolls under the header image, and reappears briefly as it scrolls between the header image and top of page.
I've looked into some basic HTML, but there is a huge jump from basic HTML to the HTML I see when I try to edit HTML directly on my Blogger website. I just want the header image to be aligned at the very top.
Can anyone help? Anything is appreciated.
Add the css top:0 to the DIV with ID "header-outer"
Plus
Why do you have so much unnecessary markup? You could replace all of this:
<div class="header-outer">
<div class="header-cap-top cap-top">
<div class="cap-left"></div>
<div class="cap-right"></div>
</div>
<div class="fauxborder-left header-fauxborder-left">
<div class="fauxborder-right header-fauxborder-right"></div>
<div class="region-inner header-inner">
<div id="header" class="header section"><div id="Header1" class="widget Header">
<div id="header-inner">
<a style="display: block" href="http://monsemble.blogspot.ca/">
<img width="833px; " height="216px; " style="display: block" src="http://2.bp.blogspot.com/-91QDCMg_EsU/UcsYVdMvLQI/AAAAAAAAACw/Oa727KfuuBk/s1600/header.jpg" id="Header1_headerimg" alt="MONSEMBLE">
</a>
</div>
</div>
</div>
</div>
</div>
<div class="header-cap-bottom cap-bottom">
<div class="cap-left"></div>
<div class="cap-right"></div>
</div>
</div>
With:
<div class="header-outer">
<a style="display: block" href="http://monsemble.blogspot.ca/">
<img width="833px; " height="216px; " style="display: block" src="http://2.bp.blogspot.com/-91QDCMg_EsU/UcsYVdMvLQI/AAAAAAAAACw/Oa727KfuuBk/s1600/header.jpg" id="Header1_headerimg" alt="MONSEMBLE">
</a>
</div>
I faced something similar on my Blogger blog and I noticed that inspite of me switching off the navbar that comes with the Blogger website, in the the HTML code there was still a division on the top of the page for the navbar. I removed it from the template and was able to move the header image to the top of the webpage.
I removed this section of the code -
<b:section class='navbar' id='navbar' maxwidgets='1' showaddelement='no'>
<b:widget id='Navbar1' locked='true' title='Navbar' type='Navbar'>
<b:includable id='main'><script type="text/javascript">
function setAttributeOnload(object, attribute, val) {
if(window.addEventListener) {
window.addEventListener('load',
function(){ object[attribute] = val; }, false);
} else {
window.attachEvent('onload', function(){ object[attribute] = val; });
}
}
</script>
<div id="navbar-iframe-container"></div>
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
<script type="text/javascript">
gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() {
if (gapi.iframes && gapi.iframes.getContext) {
gapi.iframes.getContext().openChild({
url: 'https://www.blogger.com/navbar.g?targetBlogID\0752197236978911214706\46blogName\75MahekMody.com\46publishMode\75PUBLISH_MODE_HOSTED\46navbarType\75DISABLED\46layoutType\75LAYOUTS\46searchRoot\75http://www.mahekmody.com/search\46blogLocale\75en\46v\0752\46homepageUrl\75http://www.mahekmody.com/\46vt\0753008633957882384298',
where: document.getElementById("navbar-iframe-container"),
id: "navbar-iframe"
});
}
});
</script><script type="text/javascript">
(function() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = '//pagead2.googlesyndication.com/pagead/js/google_top_exp.js';
var head = document.getElementsByTagName('head')[0];
if (head) {
head.appendChild(script);
}})();
</script>
</b:includable>
</b:widget>
</b:section>