Jump to content

98sfsdf8

Members
  • Content count

    36
  • Joined

  • Last visited

  1. 98sfsdf8

    Cycle through different sized images on scroll

    here's the answer over at https://stackoverflow.com/a/51181849/2675647
  2. Hi all, I am trying to change through images when scrolling, (and I understand that maybe the jquery is a bit messy but it seems to be working) but i would like: - to be able to have images of different heights and widths, not all the same size (as it is now). - vertically/horizontally centered. Here is a fiddle: https://jsfiddle.net/postcolonialboy/WTkqn/486/ Thanks! HTML: <div id="contentwrapper"> <div class="centreme"> <img src="https://picsum.photos/200/200?image=1" id="animation" /> <img class="hidden" src="https://picsum.photos/200/200?image=1" /> <img class="hidden" src="https://picsum.photos/200/200?image=2" /> <img class="hidden" src="https://picsum.photos/200/200?image=3" /> <img class="hidden" src="https://picsum.photos/200/200?image=4" /> <img class="hidden" src="https://picsum.photos/200/200?image=5" /> <div id="bottommark"></div> </div> </div> CSS: body, html { height: 7000px; margin: 0; background-color: grey; } .hidden { position: absolute; top: -9999999px } #bottommark { position: absolute; bottom: 0; } #contentwrapper { width: 100%; height: 100%; position: fixed; } .centreme { position: fixed; width: 200px; /* the image width */ height: 200px; /* the image height */ top: 50%; left: 50%; margin-top: -100px; /* half the image height */ margin-left: -100px; /* half the image width */ } JS: $(document).ready(function() { var a = $(document).height(); var b = a - $("#bottommark").position().top; $(window).scroll(function() { var e = $(document).height(); var f = $(window).scrollTop(); var c = e - $("#bottommark").position().top - f; var d = b / 5; $("span").html(c); if (c > d * 4) { $("#animation").attr("src", "https://picsum.photos/200/200?image=1") } if ((c < d * 4) && (c > d * 3)) { $("#animation").attr("src", "https://picsum.photos/200/200?image=2") } if ((c < d * 3) && (c > d * 2)) { $("#animation").attr("src", "https://picsum.photos/200/200?image=3") } if (c < d * 2 && c > d * 1) { $("#animation").attr("src", "https://picsum.photos/200/200?image=4") } if (c < d) { $("#animation").attr("src", "https://picsum.photos/200/200?image=5") } }) });
  3. 98sfsdf8

    Linkify (plain url to link) based on windowSize

    Nice solution from @jakecigar in the jquery forums HTML: <div>https://www.google.com/</div> <div>https://www.yahoo.com/</div> CSS: @media only screen and (max-width: 1000px) { .abbr { font-size:0; text-decoration:none; } .abbr:after { display: inline; font-size:16px; content: "link"; color:black; } } JS: $(function() { $('div').each(function() { $(this).html($(this).html().replace(/((http|https|ftp):\/\/[\w?=&.\/-;#~%-]+(?![\w\s?&.\/;#~%"=-]*>))/g, '<a class=abbr href="$1">$1</a> ')); }); })
  4. Hi all, this is what i would like to do 1. when window size is < 1000, change any plain text url to a clickable one 2. when window size is > 1000, change any plain text url to a clickable one, replaced by the word "Link". I had a go but it seems to be failing somewhere! Anyone can shed some light? Thanks HTML <html> <head> <script src="https://code.jquery.com/jquery-3.1.0.js"></script> <script>$(document).ready(function() { function checkWidth() { var windowSize = $(window).width(); if (windowSize < 1000) { $('div').each(function(){ $(this).html( $(this).html().replace(/((http|https|ftp):\/\/[\w?=&.\/-;#~%-]+(?![\w\s?&.\/;#~%"=-]*>))/g, '<a href="$1">$1</a> ') ); }); } //make plain text url clickable else if (windowSize < 1000) { $('div').each(function(){ $(this).html( $(this).html().replace(/((http|https|ftp):\/\/[\w?=&.\/-;#~%-]+(?![\w\s?&.\/;#~%"=-]*>))/g, '<a href="Link">Link</a> ') ); }); } //convert plain text to clickable word "Link" } checkWidth(); $(window).resize(checkWidth); $(window).onload(checkWidth); }); </script> </head> <body> <div>https://www.google.com/</div> <div>https://www.yahoo.com/</div> </body> </html>
  5. working now thanks to @m_hutley over at sitepoint forums <html> <head> <script src="https://code.jquery.com/jquery-3.1.0.js"></script> <script> var spData=null;function doData(a){spData=a.feed.entry}function drawCell(b,c,a){var d=$(a?"<th/>":"<td/>");b.append(d);d.append(c);return d}function drawRow(a,e,d){if(e==null){return null}if(e.length==0){return null}var b=$("<tr/>");if(d){b.addClass("head")}a.append(b);for(var f=0;f<e.length;f++){drawCell(b,e[f],((f==0)||d))}return b}function drawTable(a){var b=$("<table/>");a.append(b);return b}function readData(b){var f=spData;var d=drawTable(b);var e=[];var h=0;for(var c=0;c<f.length;c++){var a=f[c]["gs$cell"];var g=a["$t"];if(a.col==1){drawRow(d,e,(h==1));e=[];h++}e.push(g)}drawRow(d,e,(h==1))}; function loadAndColor(data) { doData(data); readData($("#data")); //Hide Row based on Phrase $("#data tr:contains('E9')").hide(); //change color of phrase: B10 $("#data td:contains('B10')").each(function() { $(this).html($(this).html().replace(/\bB10\b/ig,'<span style="color:green;">B10</span>'))}); }; </script> </head> <body> <div class="box-table" id="spreadsheet" style="overflow-x:auto!important;"> <div id="data"></div> <script src="https://spreadsheets.google.com/feeds/cells/1LM353z3Q8EeYVC2Lpxta8p4U4QBP_ih8vzERA9dh_D4/1/public/values?alt=json-in-script&callback=loadAndColor"> </script> </div> </body> </html>
  6. Hi all, I am using jquery to convert a google spreadsheet to JSON that produces a HTML table. I would like to: - hide one of the rows that has the phrase "E9" in it. - change the color of the phrase "C12" to red. I have tried many scripts, but to no avail! Here is the code I currently have. Thank you very much! <html> <head> <script src="https://code.jquery.com/jquery-3.1.0.js"></script> <script> //google spreadsheet var spData=null;function doData(a){spData=a.feed.entry}function drawCell(b,c,a){var d=$(a?"<th/>":"<td/>");b.append(d);d.append(c);return d}function drawRow(a,e,d){if(e==null){return null}if(e.length==0){return null}var b=$("<tr/>");if(d){b.addClass("head")}a.append(b);for(var f=0;f<e.length;f++){drawCell(b,e[f],((f==0)||d))}return b}function drawTable(a){var b=$("<table/>");a.append(b);return b}function readData(b){var f=spData;var d=drawTable(b);var e=[];var h=0;for(var c=0;c<f.length;c++){var a=f[c]["gs$cell"];var g=a["$t"];if(a.col==1){drawRow(d,e,(h==1));e=[];h++}e.push(g)}drawRow(d,e,(h==1))}$(document).ready(function(){readData($("#data"))}); //Hide Row based on Phrase $("#data tr:contains('E9')").hide (); //change color of phrase: C12 $('table').each(function(){ $(this).html( $(this).html() .replace( /(?<!-)(\bC12\b)(?!([^<]+)?>)(?!-)/ig, '<span style="color:green;">$1</span>' ) ); }); </script> </head> <body> <script src="https://spreadsheets.google.com/feeds/cells/1LM353z3Q8EeYVC2Lpxta8p4U4QBP_ih8vzERA9dh_D4/1/public/values?alt=json-in-script&callback=doData"> </script> <div class="box-table" id="spreadsheet" style="overflow-x:auto!important;"> <table id="data"></table> </div> </body> </html>
  7. 98sfsdf8

    Centering Custom Google Map Pins

    i've just answered my own question by adding directly after "var bounds = new google.maps.LatLngBounds();" the following: map.fitBounds(bounds); map.panToBounds(bounds);
  8. 98sfsdf8

    Centering Custom Google Map Pins

    Hi All, I am having some big trouble trying to get my custom google map pins centered, and zoomed-in to show them all at the same time. Can anyone perhaps spot why this isn't working!? Here is the code below: Thanks !!! var scriptFolder = location.pathname.substr(0, location.pathname.lastIndexOf('/') + 1); var marker = []; var map; var lastZoom = 3; var lastSizeW = 40; var lastSizeH = 30; function initialize() { var styles = [ {"elementType": "geometry", "stylers": [{"visibility": "no"}]}, {"elementType": "labels", "stylers": [{"visibility": "no"}]}, {"stylers": [{"color": "#ffffff"}, {"visibility": "yes"}]}, {} ]; var styledMap = new google.maps.StyledMapType(styles); var centerlatlng = new google.maps.LatLng(0, 0); var myOptions = { zoom: 3 , center: centerlatlng , styles: styles , panControl: true , zoomControl: false , mapTypeControl: false , scaleControl: false , streetViewControl: false , overviewMapControl: false , rotateControl: true , disableDefaultUI: true , mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById("map"), myOptions); var zoomControlDiv = document.createElement('div'); var zoomControl = new ZoomControl(zoomControlDiv, map); var image_bar = document.getElementById("pin_image_bar"); zoomControlDiv.index = 1; map.controls[google.maps.ControlPosition.RIGHT_BOTTOM].push(zoomControlDiv); map.controls[google.maps.ControlPosition.RIGHT_TOP].push(image_bar); createMarker(); google.maps.event.addDomListener(map, 'zoom_changed', function () { var zoom = map.getZoom(); if (zoom > lastZoom) { lastSizeW = lastSizeW + 40; lastSizeH = lastSizeH + 30; for (i in marker) { var image = new google.maps.MarkerImage(scriptFolder + "" + pins[i].Image, null, null, null, new google.maps.Size(lastSizeW, lastSizeH)); marker[i].setIcon(image); } } else { if (lastSizeW != 40 && lastSizeH != 30) { lastSizeW = lastSizeW - 40; lastSizeH = lastSizeH - 30; } for (i in marker) { var image = new google.maps.MarkerImage(scriptFolder + "" + pins[i].Image, null, null, null, new google.maps.Size(lastSizeW, lastSizeH)); marker[i].setIcon(image); } } lastZoom = zoom; }); $('#map').children().closest('div').append(' <video loop="" autoplay="" poster="image_xi_logo_01.png" style="position: absolute; top: 50%; left: 50%; -webkit-transform: translateX(-50%) translateY(-50%); transform: translateX(-50%) translateY(-50%); min-width: 100%; min-height: 100%; width: auto; height: auto; overflow: hidden;opacity:0.7;"><source src="video_xi_bg_05a.webm" type="video/webm"> </video>'); $('.gm-style').children().children().closest('div').addClass('pins'); } function createMarker() { var bounds = new google.maps.LatLngBounds(); for (i in pins) { var position = new google.maps.LatLng(pins[i].Lat, pins[i].Lng); var image = new google.maps.MarkerImage(scriptFolder + "" + pins[i].Image, null, /* size is determined at runtime */ null, /* origin is 0,0 */ null, /* anchor is bottom center of the scaled image */ new google.maps.Size(lastSizeW, lastSizeH)); marker[i] = new google.maps.Marker({ map: map , title: pins[i].Name , position: position , icon: image }); /*var content = '<div id="iw-container">'; content += '<div class="iw-title">'+pins[i].Info.Title+'</div>'; content += '<div class="iw-content">'; content += '<div class="iw-subTitle">'+pins[i].Info.Content.Title+'</div>'; content += '<img src="images/'+pins[i].Image+'" alt="'+pins[i].Info.Title+'" height="115" width="83">'; content += '<p>'+pins[i].Info.Content.Detail+'</p>'; content += '</div>'; content += '<div class="iw-bottom-gradient"></div>'; content += '</div>';*/ bounds.extend(marker[i].getPosition()); marker[i].pinDetail = pins[i]; google.maps.event.addListener(marker[i], 'click', function () { $("#pname").html(this.pinDetail.Name); var image = "<img src='" + this.pinDetail.Image + "' style='visibility:visible;'/>" $("#pimage").html(image); $("#ptitle").html(this.pinDetail.Info.Title); $("#pcontent").html(this.pinDetail.Info.Content); document.getElementById('pin_image_bar').style.display=''; document.getElementById('overlay').style.display=''; $('#overlay').show(); $('#pin_image_bar').show(); }); } } function ZoomControl(controlDiv, map) {}
  9. hi all, I have successfully set up a redirected form that works on submission using by using the following <script type="text/javascript">var submitted=false;</script> <iframe name="hidden_iframe" id="hidden_iframe" style="display:none;" onload="if(submitted) {window.location='whateveryourredirectis.html';}"></iframe> <form action="YOUR GOOGLE FORM" method="post" target="hidden_iframe" onsubmit="submitted=true;"> BUT, I have a couple of requirements on my form (ie. maximum characters etc.) that if they return an error, the form gets redirected to the original form saying ""Looks like you have a question or two that still needs attention." Does anyone know if I can still have my submission redirect AND also have a redirect for errors (or better still to list the error on my custom form)? thanks!
  10. Hi All, I am using a pure css template for modal popups. I would like to know how to make a link to an already 'poppedup' modal so I can share it. Thanks Fiddle HTML <label for="modal1">OPEN</label> <input type="checkbox" class="modal" id="modal1"> <div class="modal"> <article> <p>Modal content here!</p> </article> <label for="modal1" class="close"></label> <label for="modal1" class="overlay"></label> </div> CSS label { color: #00f; text-decoration: underline; cursor: pointer } .modal, .modal * { box-sizing: border-box; -moz-box-size: border-box; transition: all .2s ease-in-out } .modal:checked+.modal { opacity: 1; pointer-events: all } .modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 500; padding: 15px; overflow-y: scroll; opacity: 0; pointer-events: none } .modal article { background: #fff; width: 100%; padding: 50px; position: relative; z-index: 700 } .modal .close:before { content: '×'; display: block; padding: 20px 30px; font-size: 200%; position: absolute; top: 0; right: 0; z-index: 800; cursor: pointer } .modal .close:hover:before { color: #c00 } .modal .overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, .5); z-index: 600; cursor: pointer }
  11. ok i went for a cheap way out. which is to just switch div content using jquery. therefore i will make a separate image that simulates a blue filter, then the caption is working well too. https://jsfiddle.net/postcolonialboy/mc0fc9c8/ thanks anyway
  12. i am trying to acheive: whenever you hover over the png (the book) a blue background appears that covers the image and the text appears as welll
  13. Hi All, As you can see by this fiddle, everything is working great, except i would like the blue that is behind the text that is reveal on hover, to cover the entire icon (ie. until where the transparency begins) Any ideas? Thanks HTML <label for="modal_2"> <a class="img-hover"> <div class="item nudge1 width1 cat-2 cat-4" id="bg1"> <div class="overlay" style="background-image:url(http://gk-usa.org/wp-content/uploads/2014/06/learn-icon.png);background-size:cover;top: 0; left: 0;"> <span class='caption'>Hello World</span> </div> </div> </a> </label> CSS a.img-hover:hover { -webkit-filter: drop-shadow(0px 0px 10px #00F); filter: drop-shadow(0px 0px 10px #00F); } #bg1 { width: 90vmin; height: 90vmin; margin: 0 auto; -webkit-filter: blur(50px); filter: blur(50px); background-size: cover; -webkit-animation: sharpen 4s; animation: sharpen 4s; -webkit-animation-delay: 0s; animation-delay: 0s; -webkit-animation-fill-mode: forwards; animation-fill-mode: forwards; } #bg1::after { content: ''; -webkit-animation: preload 1s; animation: preload 1s; -webkit-animation-delay: 1s; animation-delay: 1s; } @-webkit-keyframes preload{0%{background-image:url(http://gk-usa.org/wp-content/uploads/2014/06/learn-icon.png)} } @keyframes preload{0%{background-image:url(http://gk-usa.org/wp-content/uploads/2014/06/learn-icon.png)} } @-webkit-keyframes sharpen{0%{background-image:url(http://gk-usa.org/wp-content/uploads/2014/06/learn-icon.png);-webkit-filter:blur(20px);filter:blur(20px)} 100%{background-image:url(http://gk-usa.org/wp-content/uploads/2014/06/learn-icon.png);-webkit-filter:blur(0px);filter:blur(0px)} } @keyframes sharpen{0%{background-image:url(http://gk-usa.org/wp-content/uploads/2014/06/learn-icon.png);-webkit-filter:blur(20px);filter:blur(20px)} 100%{background-image:url(http://gk-usa.org/wp-content/uploads/2014/06/learn-icon.png);-webkit-filter:blur(0px);filter:blur(0px)} } /*Isotope Divs */ .item { font-size: 8pt; text-align: justify; float: left; width: 332px; height: 213px; background: 0; margin: 80px; border: 0px solid black; } .overlay { opacity: 0; height: 100%; text-align: center; -webkit-transition: all .2s ease-out; -moz-transition: all .2s ease-out; -o-transition: all .2s ease-out; -ms-transition: all .2s ease-out; transition: all .2s ease-out; } .item:hover .overlay { opacity: 1; height: 100%; text-align: center; } .caption {z-index:100; color: white; opacity: 0; position: relative; top: 50%; background-color: rgba(0, 0, 255, .60); -webkit-transform: translateY(-50%); -ms-transform: translateY(-50%); transform: translateY(-50%); -webkit-transition: all .4s ease-out 0.4s; -moz-transition: all .4s ease-out 0.4s; -o-transition: all .4s ease-out 0.4s; -ms-transition: all .4s ease-out 0.4s; transition: all .4s ease-out 0.4s; } .item:hover .caption { opacity: 1; }
  14. Hello all, I am currently using jquery + "isotrope" to make an image gallery where images can be filtered using "data-filters". But "Isotope" uses grids to organise the divs but I would like something like the following image which is kind of free of a grid or random positioning. Do you know how I can tweak "Isotrope" to make it appear more loose or free from some masonry or grid-like system? The closest I got was the attempt below, but as you can see in the jsfiddle, there is no gutter between the divs and it still looks very much like a grid. Fiddle: https://jsfiddle.net/postcolonialboy/w31L4wkw/ HTML <div class="isotope"> <div class="item cat-2 height2 width2 cat-4">width3</div> <div class="item height2 width2 cat-4">height2</div> <div class="item cat-2">normal</div> <div class="item cat-1 height3 width3">height3</div> <div class="item cat-2 cat-4 height3 width3">normal</div> <div class="item cat-2">normal</div> <div class="item cat-2 cat-3">normal</div> <div class="item height2 width2">width2 height3</div> <div class="item height2 width2">width2</div> <div class="item height2 width2 cat-4">width2</div> <div class="item cat-1 height2 width2">height2</div> <div class="item cat-2 cat-3 height3 width3">width3</div> <div class="item cat-3 height3 width3">height3</div> <div class="item cat-3 width2 height2 cat-1">width2 height2</div> <div class="item height2 width2 cat-4 cat-1">width2</div> <div class="item height2 width2 cat-3">height2</div> <div class="item cat-1 cat-3 height3 width3">width3</div> </div> JS jQuery(window).on("load resize", function(e) { var $container = $('.isotope'), colWidth = function() { var w = $container.width(), columnNum = 1, columnWidth = 0; //Select what will be your projects columns according to container width if (w > 1040) { columnNum = 6; } else if (w > 850) { columnNum = 5; } else if (w > 768) { columnNum = 4; } else if (w > 480) { columnNum = 3; } else if (w > 300) { columnNum = 2; } columnWidth = Math.floor(w / columnNum); //Default item width and height $container.find('.item').each(function() { var $item = $(this), width = columnWidth, height = columnWidth; $item.css({ width: width, height: height }); }); //2.4x width item width and height $container.find('.width2').each(function() { var $item = $(this), width = columnWidth * 2.4, height = columnWidth; $item.css({ width: width, height: height }); }); //2.4x height item width and height $container.find('.height2').each(function() { var $item = $(this), width = columnWidth, height = columnWidth * 2.4; $item.css({ width: width, height: height }); }); //2.4x item width and height $container.find('.width2.height2').each(function() { var $item = $(this), width = columnWidth * 2.4, height = columnWidth * 2.4; $item.css({ width: width, height: height }); }); //3.3x width item width and height $container.find('.width3').each(function() { var $item = $(this), width = columnWidth * 3.3, height = columnWidth; $item.css({ width: width, height: height }); }); //3.3x height item width and height $container.find('.height3').each(function() { var $item = $(this), width = columnWidth, height = columnWidth * 3.3; $item.css({ width: width, height: height }); }); //3.3x item width and height $container.find('.width3.height3').each(function() { var $item = $(this), width = columnWidth * 3.3, height = columnWidth * 3.3; $item.css({ width: width, height: height }); }); return columnWidth; }, isotope = function() { $container.isotope({ resizable: true, itemSelector: '.item', masonry: { columnWidth: colWidth(), gutterWidth: 15, } }); }; isotope(); CSS * { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box } body { font-family: "Helvetica Neue", sans-serif; max-width: 95%; margin: 0 auto; padding-top: 5%; } .isotope { background: 0; max-width: 95%; margin: 0 auto } .isotope:after { content: ''; display: block; clear: both } .item { float: left; width: 332px; height: 213px; background: 0; border: 1px solid black } .item.width2 { width: 321px; } .item.height2 { height: 342px; } .item.width3 { width: 472px; } .item.height3 { height: 431px; } Thanks
  15. 98sfsdf8

    SwitchClass using jquery makes for choppy animation

    i went for this option and it works fine. i still wasn't able to trigger it using the esc key... html <div class="title">Text</div> js $(function(){ $("div.title").click(function() { $(this).addClass("title-after"); }); }) css .title { z-index: 100; font-size:25vw; color: blue; text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000; font-weight: 600; text-rendering: optimizeLegibility; position:fixed; display:inline-block; left: 25vw; top: calc(50vh - 12.5vw); background-color: none; -webkit-filter: blur(1.0vw) saturate(400%) contrast(500%); filter: blur(1.0vw) saturate(400%) contrast(500%); transition-property: all; transition-duration:1.0s; transition-timing-function: ease-out; } .title-after { font-size: 10vw; position:fixed; margin: 0px; top: 0px; left: 0px; background-color: none; -webkit-filter: blur(0.4vw) saturate(400%) contrast(500%); filter: blur(0.4vw) saturate(400%) contrast(500%); }
×