Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
Dardan Demiri
@dardandemiri
Try adding to the ul class :smile:
justify-content-center
Frosty427
@Frosty427
ok thanks ill try @dardandemiri
CamperBot
@camperbot
frosty427 sends brownie points to @dardandemiri :sparkles: :thumbsup: :sparkles:
:cookie: 429 | @dardandemiri |http://www.freecodecamp.org/dardandemiri
Dardan Demiri
@dardandemiri
;)
Connor
@cresharper
Anyone here good at regex?
Dardan Demiri
@dardandmr
@cresharper We will try
;)
how can we help you ?
Connor
@cresharper
Nevermind, I figured it out but thanks!
Calat
@latimercaleb
Hello all, the prodigal son returns
Ken Haduch
@khaduch
@latimercaleb welcome back!
Calat
@latimercaleb
I left off with the random quote machine project. So I'll be building that out since I'm in between tickets at work. How is everyone else doing?
Daniel Watson
@itsdanwatson
Going through my Blackjack Card Counting function. I've gone through a switch statement, and now need to create an if statement to decide what to do with the results of the switch
Darren
@DarrenfJ
@coderNewby hey got your PM sorry.. was off sick the last day or so.. looks good though.. go check it out
coderNewby
@coderNewby
@DarrenfJ thanks! no worries.. I'm busy in the middle of the bootstrap...thanks again for the help
CamperBot
@camperbot
codernewby sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 2422 | @darrenfj |http://www.freecodecamp.org/darrenfj
NikolaNbgd
@NikolaNbgd
Hi folks! I have a big API call on the bottom of the website, so I want to display data only when user scroll to that section. I made it, but my API is called each time around when user scroll in that area. I tried 'one' jquery function, that solution doesn't work for me. Any help? Advice? Many thanks!
Dardan Demiri
@dardandmr
@NikolaNbgd you can try using a setTimeout()
when the user arrives in that area, it starts onece
never again
NikolaNbgd
@NikolaNbgd
@dardandmr how that can help me?
Dardan Demiri
@dardandmr
right now you have made the code run every time the user scrolls down right ?
NikolaNbgd
@NikolaNbgd
yep, but only when user sroll to that section
I can send you that piece of code
Dardan Demiri
@dardandmr
Great idea
NikolaNbgd
@NikolaNbgd
$(document).ready(function () {
$(window).on('scroll', function () {
var hT = $('.forks_me').offset().top,
hH = $('.forks_me').outerHeight(),
wH = $(window).height(),
wS = $(this).scrollTop();
if (wS > (hT + hH - wH) && window.location.pathname == '/') {
getApi();
console.log('works')
}
})
});
Dardan Demiri
@dardandmr
window.addEventListener('scroll', function(){
  var place = document.body.scrollTop;
  var alertOn = document.getElementById('anotherElement').offsetTop;
  if(place > alertOn){
    alert('Function execute here');
    this.removeEventListener('scroll', arguments.callee, false);
  }
});


anotherElement is the ID of the section you want to execute
window.addEventListener('scroll', function(){
  var place = document.body.scrollTop;
  var alertOn = document.getElementById('anotherElement').offsetTop;
  if(place > alertOn){
    getApi();
    console.log('works')
    this.removeEventListener('scroll', arguments.callee, false);
  }
});
This should work as you asked for
Calat
@latimercaleb
Crap, how do you format code in here again ? It's been so long.
Dardan Demiri
@dardandmr
with three ```
Dardan Demiri
@dardandmr
then the code under
Calat
@latimercaleb
Ahhh thanks guys
Dardan Demiri
@dardandmr
;)

@latimercaleb Whenever you want to see this image sent by @gulsvi

Just pres Ctrl+Shift+M

Gulsvi
@gulsvi
@NikolaNbgd can you check if an element has been populated with API data and conditionally call getApi() based on that?
if(!$("#myElement").text().trim().length) getApi();
NikolaNbgd
@NikolaNbgd
@dardandmr well, nothing happens, my data even aren't loaded
Dardan Demiri
@dardandmr
Can you put the whole code in Codepen
@NikolaNbgd here see an example
with jQueyr
jQuery
NikolaNbgd
@NikolaNbgd
@gulsvi yeah, but my div is empty until user scroll to desired section
Gulsvi
@gulsvi
@NikolaNbgd Right, so when it is no longer empty, no need to call the api. Or, set a flag to determine if the API has been called:
var api = false;

$(document).ready(function() {
  $(window).on("scroll", function() {
    var hT = $(".forks_me").offset().top,
      hH = $(".forks_me").outerHeight(),
      wH = $(window).height(),
      wS = $(this).scrollTop();
    if (wS > hT + hH - wH) getApi();
  });
});

function getApi() {
  if (!api) console.log("works");
  api = true;  
}
Run that code and you'll see "works" once in the console, instead of it appearing multiple times every time the user scrolls
NikolaNbgd
@NikolaNbgd
@dardandmr oh, need a week to put all my code in codepen, its a really big project, can we find some other solution? :/
Dardan Demiri
@dardandmr

Can you please explain this in more details:

I made it, but my API is called each time around when user scroll in that area.