Rep. Ryan Costello (R-Pa.) decided he would rather retire than run an uphill campaign for his seat in the Philadelphia suburbs after the state’s top court drew a new congressional map. (Alex Wong/Getty Images)

All you need to know about political momentum can be found in Philadelphia’s western suburbs by looking at two campaigns.

Doug Hasbrouck, faced with almost certain defeat, decided last year to jump into his first campaign. Rep. Ryan Costello, a rising political star, stared down a very difficult race and quit elective politics.

Hasbrouck, 56, a lifelong Democrat, had never really gotten involved in politics until after President Trump’s inauguration. When local party leaders asked him to run for a township council seat last fall, he knew Republicans had a major advantage. He still dove in because even in defeat, his campaign might draw out more Democrats to help other races.

“For the ticket, I was at the bottom,” Hasbrouck said last Sunday at a gathering of local Democrats here in Delaware County.

Just 41 years old, Costello had already served on a township board of supervisors and a county board, doing stints as chairman for both. A classic moderate Republican, Costello is now in his second term in Congress. When the state Supreme Court drew new maps, his district went from a pure toss-up to one Trump lost by nearly 10 percentage points.

But he has grown sick of answering questions about the unpredictable president and decided he would retire rather than run an uphill campaign for a job he barely enjoys. “It’s very difficult to move forward in a constructive way today,” Costello told Michael Rellahan, dean of the political press corps in Chester County, just west of Delaware County.

Democrats in this region are poised to meet or exceed their share of what’s needed to win the House majority. Costello is one of three Republicans retiring in southeastern Pennsylvania, and Democrats have the edge in all three districts. In southern New Jersey, Republicans have not found a top-tier candidate to succeed a retiring veteran lawmaker, but Democrats have their top pick in the race.

North of Philadelphia, on both sides of the Delaware River, a pair of incumbent Republicans are facing difficult reelection battles.

By the time all the votes are counted, Democrats might well pick up five or six seats in the Philadelphia area — a huge head start on the way to netting the 23 needed to win the majority in November’s midterm elections.

And all of that is fueled by the anti-Trump energy in these once Republican strongholds in the suburbs, where the ground shifted in presidential races long ago but now is moving toward the Democrats at the most local level.

While most political observers focused on the Virginia elections this past fall, the ground shook here in the Philadelphia suburbs as never before. For the first time in Delaware County history, Democrats swept the countywide offices and won their first seats on the council in nearly 40 years.

In one school board election, Democrats won four out of four contests on a panel that had been entirely Republican except for one brief stretch in 1980.

David Landau, chairman of the Delaware County Democrats, saw last year’s local elections as the prelude to this year’s congressional elections.

“The path to 2018 is 2017,” he recalled telling his party activists last year. “You want to change Washington? Change Delaware County.”

Next door, in Costello’s Chester County, the same thing happened. All four county “row offices,” posts such as auditor and clerk of the courts, went to the Democrats — offices Democrats had never before held.

So Costello knew he would face a tough 2018 election and started working immediately. In 2017, he raised nearly $1.6 million and had a war chest of $1.4 million. He positioned himself independently on issues, opposing the repeal of the Affordable Care Act while supporting the massive tax-cut plan.

Independent analysts rated his race a toss-up. Then the court ruled that the current maps violated the state constitution’s requirement that counties not be carved apart in creating representative districts. The new map places all of Chester and part of Berks County into one district, a much more Democratic division.

Costello decided against running an uphill race, particularly in an environment in which liberals deride him as a Trump enabler. “It’s a very angry environment,” he told the Daily Local News in Chester County.

That energy could be found at last Sunday night’s meeting of the Mid-County Democratic Committee, covering a collection of five towns in Delaware County.

“Four years, ago this group had about 12 people. We now have 70 or 80,” said Bill Clinton, 72, who has been active in local grass-roots politics for more than 15 years and happily jokes about his presidential name.

On that night, seven candidates for the newly drawn congressional district here turned out for a candidate forum. It was only half the field of 14 candidates, as the county organization builds toward making an endorsement to ensure that they do not nominate a fluky candidate who might give away what should be a sure thing.

The once-popular incumbent here, Rep. Patrick Meehan (R-Pa.), had won four congressional elections by wide margins no matter the political environment. But Meehan announced he would not run this year after he faced a sexual-harassment scandal and then the court changed this district from a toss-up to one Trump lost by a double-digit margin.

Hasbrouck and dozens of other activists skipped the chance to watch Stormy Daniels on CBS’s “60 Minutes” discussing her alleged affair with Trump and instead listened to the congressional candidates give detailed answers on many policy questions.

His experience last year only got him more energized about politics. His district of the Upper Providence council had a roughly 10 percent edge for Republicans in voter registration, so he saw little chance of winning.

But he knew there were countywide races at stake, and all the votes he got for himself probably would be additional votes for those Democrats. Recognizing how hard Hasbrouck was campaigning, local Republicans began a rescue mission late in the race.

He lost by 50 votes. Turnout was twice as high as expected.

Now, he wants to harness that energy for the congressional races this fall. And he has just one litmus test: “I’m wedded to the candidate that can win.”

Read more from Paul Kane’s archive, follow him on Twitter or subscribe to his updates on Facebook.