Fullcalendar event content sticky - fullcalendar

im trying to make the content inside of an event in the Fullcalendar sticky. When you scroll in the calendar the content of the events should be visible as long as the event isn't out of the view.
I tried it with simple css but that doesn't work, see for yourself:
.fc-event .fc-content {
position:sticky;
top:0;
}
https://codepen.io/snak3/pen/KZKNMd
Has anyone an idea how to get this working or isn't it that easy?

It's not possible to use position:sticky out of the box, but here's an example of how you might go about it with js (add this to the end of your script):
const content = document.querySelectorAll('.fc-event .fc-content')[1];
const scroller = document.querySelector('.fc-scroller');
scroller.addEventListener("scroll", function() {
if (scroller.scrollTop > 100) {
content.style.position = "fixed";
content.style.top = "130px";
}
else {
content.style.position = "unset";
}
});
Obviously the selector and top values are very specific. You can use js to calculate the appropriate top distance for each event, and apply it for each scroll proc. That is a lot of work though.

Related

Smooth scroll automatically starts on page load

I am new to programming. I wanted to create a smooth scrolling effect when I click on an href on my page, to do so I have used the scroll behavior:smooth in css. I've applied the rule like this
html {
scroll-behavior: smooth;
}
Otherwise it works great, but there's a consequence that I do not wish is there, on page load it automatically smooth scrolls to the identifier that's applied onto the href. I want to avoid this, how can I do that?
Thank you.
try this:
<script>
window.onload = function() {
var node = document.createElement('style');
node.innerHTML = "html {scroll-behavior: smooth;}";
document.body.appendChild(node);
};
</script>

How to set a div to change its background and alpha levels upon scrolling

I am looking at websites for inspiration for my new start ups homepage. I saw https://www.pactcoffee.com/ and their home page features a full background image for the header and the nav bar is transparent then it becomes a solid color nav bar as you scroll down. I have only been able to set up the CSS for the site but I don't understand what to do to have the change in nav bar color.
You can do something like this...
http://jsfiddle.net/ojcqbLr2/
Check the Fiddle to see the rest of the code... like the CSS.
This JS will do this.
$(document).scroll(function () {
var y = $(this).scrollTop();
if (y > 100) {
$('.topMenu').fadeIn();
} else {
$('.topMenu').fadeOut();
} });
By the way, I found this info by search.
Show div on scrollDown after 800px
I just made edits to the code so it was at the top and not bottom.
Best of luck.
I have found that you can set two divs. One of which will be display set to none.
$(document).scroll(function () {
var headerHeight = $('header').height(),
s = $('.nav'),
y = $(this).scrollTop();
if (y > headerHeight) {
$('.navLong').fadeIn();
$('.nav').fadeOut();
} else {
$('.navLong').fadeOut();
$('.nav').fadeIn();
}});
This allows one div to disappear when one appears and vice versa. A working example is can be found in the DEMO

CSS Position Fixing

I have managed to use the position:fixed setting of CSS/CSS3 before and worked quite well!
I saw this a few days ago and was wondering how did they achieve the effect that happens when you scroll down, where the menu bar is in one position before you scroll and then goes to the top where it locks itself down.
See link - http://www.cssportal.com/ < scroll down on any page and observe the top blue menu.
I have tried to look in the source of the page but I cant make head or tails.
Does anyone know what this effect is called?
It's done with javascript, to add a css class that contains position:fixed and other positioning styles to achieve what you want.
It's not complicated. Here is a jquery plugin: http://stickyjs.com/
This is how I did it a few years ago:
var menu_bar = $("#menu");
var top = menu_bar.offset().top;
var detached = false;
$(window).scroll(function (e) {
if ($(this).scrollTop() >= top) {
if (!detached) {
detached = true;
menu_bar.addClass('fixed');
}
} else {
if (detached) {
detached = false;
menu_bar.removeClass('fixed');
}
}
});

CSS: overflow-y: scroll; overflow-x: visible

See the following post for a picture highlighting my question and a potential solution:
CSS overflow-y:visible, overflow-x:scroll
However, this strategy breaks when you actually move the scrollbar. In the suggested implementation (position: fixed;), the tooltips display next to child div in its position pre-scroll. So, as you scroll new child-divs into view, the tooltips begin falling off the bottom of the page.
See here for a demo of the bug: http://jsfiddle.net/narcV/4/
Any ideas how I can make the tooltips display next to the child div at all times?
I ended up implementing this using javascript, using the getPos function from this question.
The end product looks like:
var scrollPanel = ...;
var tooltip = ...;
function nodeHovered(e) {
var hovered = e.srcElement;
var pos = getPos(hovered);
pos.x += hovered.offsetWidth;
pos.y -= scrollPanel.scrollTop;
tooltip.style.setProperty('left', pos.x);
tooltip.style.setProperty('top', pos.y);
}
Basically, I calculate where on the page the node is currently displayed (taking into account the scrollbar position), and manually place the tooltip in the right spot on the page.
Too bad there's no elegant/CSS way to do this, but at least this works.

Attach a div to Dojo DataGrid horizontal scroll

I have a fixed width datagrid being built programatically, and am trying to put a header over top of it that will scroll with it. I can't do it as part of the grid as that destroys the fixed width of the cells.
I would like to be able to scroll the top div as the scrollbar for the DataGrid scrolls. This seems how the header works already, so it should be possible. I just can't figure out how to link/attach it.
Ok, I figured it out... if anyone is interested. You need to extend _View to include what you want to update. The hardest part about this is getting the div structure laid out so it works in IE and FF, just really duplicated what was there for the datagrid header that was already being scrolled. Here is the declare:
dojo.declare("custom.View", dojox.grid._View, {
doscroll: function(inEvent) {
this.inherited(arguments);
var customHeader = dojo.byId('customGridHeader');
if (customHeader) {
customHeader.scrollLeft = this.scrollboxNode.scrollLeft;
}
},
update: function(){
this.inherited(arguments);
var customHeader = dojo.byId('customGridHeader');
if (customHeader) {
customHeader.scrollLeft = this.scrollboxNode.scrollLeft;
}
}
});

Resources