Есть svg-карта, поверх которой всплывает поп-ап с информацией о провинциях (#provinceInfo).
В этом поп-апе у меня не работает прокрутка текста, поскольку слой карты каким-то образом
оказывается над слоем поп-апа и мышка взаимодействует с картой, а не с поп-апом. Пробовал
настроить z-индекс, но не помогло. Большое спасибо за советы!
var canadamap = document.getElementById("canada-map"),
provinceInfo = document.getElementById("provinceInfo"),
allProvinces = canadamap.querySelectorAll("g");
canadamap.addEventListener("click", function(e){
var province = e.target.parentNode;
if(e.target.nodeName == "path") {
for (var i=0; i < allProvinces.length; i++) {
allProvinces[i].classList.remove("active");
}
province.classList.add("active");
var provinceName = province.querySelector("title").innerHTML,
provincePara = province.querySelector("desc p");
sourceImg = province.querySelector("img"),
imgPath = "https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/";
provinceInfo.innerHTML = "";
provinceInfo.insertAdjacentHTML("afterbegin", ""+provinceName+" "+provincePara.innerHTML+"
");
provinceInfo.classList.add("show");
}
})
* {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
body {
background: #88a;
color: #fff;
font-family: Avenir, Calibri, sans-serif;
}
#canada-map {
fill: #174f17;
}
#canada-map g {
-webkit-transition: .3s;
transition: .3s;
}
#canada-map g:hover {
fill: #2e9e2e;
cursor: pointer;
}
.active, .active:hover {
fill: #2e2e9e !important;
}
#provinceInfo {
position: absolute;
top: 0;
right: 0;
width: 25%;
background: rgba(0, 0, 0, 0.2);
pointer-events: none;
opacity: 0;
-webkit-transition: 1s;
transition: 1s;
overflow: auto;
height: 75%;
}
@media all and (max-width: 800px) {
#provinceInfo {
width: 40%;
}
}
@media all and (max-width: 750px) {
#provinceInfo {
width: 100%;
position: static;
background: none;
}
#provinceInfo.show p {
color: #000 !important;
margin-bottom: 2rem;
}
}
#provinceInfo.show {
opacity: 1;
}
#provinceInfo h1 {
background: #2e2e9e;
padding: .3rem;
padding-left: 1rem;
margin-top: -.5rem;
font-weight: 400;
}
#provinceInfo p {
margin-left: 2rem;
margin-right: 2rem;
}
#provinceInfo img {
width: 100%;
}
Interactive Geographical Map w/ SVG & JavaScript
Alberta
One of Canada's four prairie provinces, and the most populous of them, Alberta
is the only one to border a single US state. It is divided from British Columbia by
the Rocky Mountains, over which run gusts of wind, known as chinooks , that can
keep the southern part of the province considerably warmer than its eastern neighbours
during the winter.
British Columbia
One of the western-most of Canada’s provinces, British Columbia is part of
the Cascadia region, bounded by the Pacific Ocean on the west and the Rocky Mountains
to the east. The environment ranges from temperate rain forest in the southern coastal
regions to extremely cold in the north.
Manitoba
Manitoba is sparsely populated, especially in the north, which is dominated
by arctic tundra and the Canadian Shield, a vast area of igneous rock that forms the
ancient geological core of the North American continent.
New Brunswick
One of Canada’s three Maritime provinces, bordering the Atlantic ocean. It
is the only constitutionally bi-lingual province (French-English), partly due to the
presence of the large Acadian population, most of whom are descended from returnees
from the mass expulsion of the Acadian people by the British during the French-Indian
war.
Newfoundland & Labrador
A unique province that consists of both an island (Newfoundland) and a portion
of the mainland (Labrador). The area has a deep history, being inhabited by the Beothuk,
Inuit, Mi'kmaq and Innu for thousands of years. European content began in 1001 CE,
when the area was temporarily settled by Vikings led by Leif Ericson.
Nova Scotia
Canada’s second-smallest province is almost completely surrounded by water. It’s
unique geographical history has also made it a valuable location for fossils, mostly
from the Carboniferous, Triassic and Jurassic periods.
Northwest Territories
Part of Canada since 1870, the Northwest Territories were subdivided in 1999
to form the territory of Nunavut, gaining the portion that has a slightly warmer climate
and taiga forest.
Nunavut
The largest Canadian territory, with a land area equivalent to Western Europe,
it is also the newest, formed in 1999, and the least populous, with just over 30,000
permanent citizens. Nunavut also holds the northernmost permanently inhabited settlement
in the world in the form of Alert, a military signals station and scientific outpost.
Ontario
Canada’s most populous province, with nearly 40% of the population, much of
it clustered around Lake Ontario and in the city of Toronto, Canada’s largest city.
Ontario also holds the nation’s capital of Ottawa.
Prince Edward Island
The smallest province in both land area and population, Prince Edward Island
grows 25% of the nation's potatoes.
Quebec
Quebec is Canada’s second-largest province, and the only one to use French as
its sole official language. Independence movements have played a significant role in
the history and politics of the province.
Saskatchewan
Saskatchewan is a completely land-locked province located near the geographical
center of the country. It's location and lack of any large open bodies of water creates
an environment with the greatest range of temperature in Canada, from 40°C in the summer
to -40°C in winter.
Yukon
The Yukon largely escaped glaciation during the last Ice Age 10,000 years ago,
making it a welcome home for the First Nations of the north. Today ¾ of the
population lives in the territory’s only city of Whitehorse; the second-largest habitation
has just 2000 people.
Ответы
Ответ 1 У вас проблема не в наложении карты на попап, а в том, что для попа выключены события
(pointer-events: none;).
var canadamap = document.getElementById("canada-map"),
provinceInfo = document.getElementById("provinceInfo"),
allProvinces = canadamap.querySelectorAll("g");
canadamap.addEventListener("click", function(e){
var province = e.target.parentNode;
if(e.target.nodeName == "path") {
for (var i=0; i < allProvinces.length; i++) {
allProvinces[i].classList.remove("active");
}
province.classList.add("active");
var provinceName = province.querySelector("title").innerHTML,
provincePara = province.querySelector("desc p");
sourceImg = province.querySelector("img"),
imgPath = "https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/";
provinceInfo.innerHTML = "";
provinceInfo.insertAdjacentHTML("afterbegin", ""+provinceName+" "+provincePara.innerHTML+"
");
provinceInfo.classList.add("show");
}
})
* {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
body {
background: #88a;
color: #fff;
font-family: Avenir, Calibri, sans-serif;
}
#canada-map {
fill: #174f17;
}
#canada-map g {
-webkit-transition: .3s;
transition: .3s;
}
#canada-map g:hover {
fill: #2e9e2e;
cursor: pointer;
}
.active, .active:hover {
fill: #2e2e9e !important;
}
#provinceInfo {
position: absolute;
top: 0;
right: 0;
width: 25%;
background: rgba(0, 0, 0, 0.2);
pointer-events: none;
opacity: 0;
-webkit-transition: 1s;
transition: 1s;
overflow: auto;
height: 75%;
}
@media all and (max-width: 800px) {
#provinceInfo {
width: 40%;
}
}
@media all and (max-width: 750px) {
#provinceInfo {
width: 100%;
position: static;
background: none;
}
#provinceInfo.show p {
color: #000 !important;
margin-bottom: 2rem;
}
}
#provinceInfo.show {
opacity: 1;
pointer-events: auto;/*Вот здесь верните все на место*/
}
#provinceInfo h1 {
background: #2e2e9e;
padding: .3rem;
padding-left: 1rem;
margin-top: -.5rem;
font-weight: 400;
}
#provinceInfo p {
margin-left: 2rem;
margin-right: 2rem;
}
#provinceInfo img {
width: 100%;
}
Interactive Geographical Map w/ SVG & JavaScript
Alberta
One of Canada's four prairie provinces, and the most populous of them, Alberta
is the only one to border a single US state. It is divided from British Columbia by
the Rocky Mountains, over which run gusts of wind, known as chinooks , that can
keep the southern part of the province considerably warmer than its eastern neighbours
during the winter.
British Columbia
One of the western-most of Canada’s provinces, British Columbia is part of
the Cascadia region, bounded by the Pacific Ocean on the west and the Rocky Mountains
to the east. The environment ranges from temperate rain forest in the southern coastal
regions to extremely cold in the north.
Manitoba
Manitoba is sparsely populated, especially in the north, which is dominated
by arctic tundra and the Canadian Shield, a vast area of igneous rock that forms the
ancient geological core of the North American continent.
New Brunswick
One of Canada’s three Maritime provinces, bordering the Atlantic ocean. It
is the only constitutionally bi-lingual province (French-English), partly due to the
presence of the large Acadian population, most of whom are descended from returnees
from the mass expulsion of the Acadian people by the British during the French-Indian
war.
Newfoundland & Labrador
A unique province that consists of both an island (Newfoundland) and a portion
of the mainland (Labrador). The area has a deep history, being inhabited by the Beothuk,
Inuit, Mi'kmaq and Innu for thousands of years. European content began in 1001 CE,
when the area was temporarily settled by Vikings led by Leif Ericson.
Nova Scotia
Canada’s second-smallest province is almost completely surrounded by water. It’s
unique geographical history has also made it a valuable location for fossils, mostly
from the Carboniferous, Triassic and Jurassic periods.
Northwest Territories
Part of Canada since 1870, the Northwest Territories were subdivided in 1999
to form the territory of Nunavut, gaining the portion that has a slightly warmer climate
and taiga forest.
Nunavut
The largest Canadian territory, with a land area equivalent to Western Europe,
it is also the newest, formed in 1999, and the least populous, with just over 30,000
permanent citizens. Nunavut also holds the northernmost permanently inhabited settlement
in the world in the form of Alert, a military signals station and scientific outpost.
Ontario
Canada’s most populous province, with nearly 40% of the population, much of
it clustered around Lake Ontario and in the city of Toronto, Canada’s largest city.
Ontario also holds the nation’s capital of Ottawa.
Prince Edward Island
The smallest province in both land area and population, Prince Edward Island
grows 25% of the nation's potatoes.
Quebec
Quebec is Canada’s second-largest province, and the only one to use French as
its sole official language. Independence movements have played a significant role in
the history and politics of the province.
Saskatchewan
Saskatchewan is a completely land-locked province located near the geographical
center of the country. It's location and lack of any large open bodies of water creates
an environment with the greatest range of temperature in Canada, from 40°C in the summer
to -40°C in winter.
Yukon
The Yukon largely escaped glaciation during the last Ice Age 10,000 years ago,
making it a welcome home for the First Nations of the north. Today ¾ of the
population lives in the territory’s only city of Whitehorse; the second-largest habitation
has just 2000 people.
Ответ 2 Замените локальный путь до изображений на сетевой ресурс
Комментариев нет:
Отправить комментарий